View Single Post
  #5  
Old 05-26-2012, 11:22 AM
podvoxx podvoxx is offline
Approved Member
 
Join Date: Feb 2010
Posts: 190
Default

My dll-file:
Code:
using System;

namespace smpcore
{    
    public static class SMPcore
    {
        public static int addNum(int x, int y)
        {
            return x + y;
        }
    }

    public sealed class Singleton
    {
        public int planeCount { get; set; }

        // Global side score
        public int redScore { get; set; }
        public int blueScore { get; set; }
        
        // Number dead units global statistic
        public int numberDeadRedPlanes { get; set; }  // aircraft unit
        public int numberDeadBluePlanes { get; set; } // aircraft unit

        public int numberDeadRedAAA { get; set; }  
        public int numberDeadBlueAAA { get; set; } 

        public int numberDeadRedTanks { get; set; }  // Tank unit
        public int numberDeadBlueTanks { get; set; } // Tank unit

        public int numberDeadRedArtillery { get; set; }  // Artillery unit
        public int numberDeadBlueArtillery { get; set; } // Artillery unit

        public int numberDeadRedCars { get; set; }  // Cars unit
        public int numberDeadBlueCars { get; set; } // Cars unit

        public int numberDeadRedShips { get; set; }  // Ships unit
        public int numberDeadBlueShips { get; set; } // Ships unit
       
        private static readonly Lazy<Singleton> lazy = new Lazy<Singleton>(() => new Singleton());

        public static Singleton GetInstance { get { return lazy.Value; } }

        private Singleton()
        {
            // Initialisations
            planeCount = 1;

            // Global side score
            redScore = 0;
            blueScore = 0;
           
            // Number dead units global statistic
            numberDeadRedPlanes = 0;  // aircraft unit
            numberDeadBluePlanes = 0; // aircraft unit

            numberDeadRedAAA = 0;
            numberDeadBlueAAA = 0; 

            numberDeadRedTanks = 0;  // Tank unit
            numberDeadBlueTanks = 0; // Tank unit

            numberDeadRedArtillery = 0;  // Artillery unit
            numberDeadBlueArtillery = 0; // Artillery unit

            numberDeadRedCars = 0;  // Cars unit
            numberDeadBlueCars = 0; // Cars unit

            numberDeadRedShips = 0;  // Ships unit
            numberDeadBlueShips = 0; // Ships unit            
        }
    }
}
My script:
Code:
//$reference "parts\core\smp.dll"
//$reference "parts\core\smpMessage.dll"
using System;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;
using smpcore;
using smpmessage;

// HOST-MISSION Script
public class Mission : AMission
{
    // =========================HOST-MISSION PARAMETERS===========================
    // Setup file and folder path
    string setupMisMPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\1C SoftClub\\il-2 sturmovik cliffs of dover\\missions\\SMP\\Friday on my mind\\system\\mission_setup.ini";
      
    int unitPlanePrice = 10;
    int unitAAAPrice = 3;
    int unitTankPrice = 10;
    int unitArtilleryPrice = 2;
    int unitCarPrice = 2;
    int unitShipPrice = 10;

    // TESTTESTTESTTESTTESTTEST 
    Singleton stat = Singleton.GetInstance;  // get access to the singleton or create it if not exist.    

    public override void OnBattleStarted()
    {
        base.OnBattleStarted();
        MissionNumberListener = -1;

        smpSendMSG.MessageToAll("BATTLE STARTED!", "Chat");

        // LOAD SUBMISSIONS
        GamePlay.gpPostMissionLoad("missions\\SMP\\Friday on my mind\\submissions\\Test1\\Test1.mis");
        GamePlay.gpPostMissionLoad("missions\\SMP\\Friday on my mind\\submissions\\Test2\\Test2.mis");
    }

    // =========================OnActorDead=============================     
    public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
    {
        base.OnActorDead(missionNumber, shortName, actor, damages);

        if (actor != null)
        {
            // AiGroundActor STATISTIC
            if (actor is AiGroundActor)
            {
                AiGroundActor groundActor = actor as AiGroundActor;
                if (groundActor != null)
                {
                    // AAArtillery points       
                    if (groundActor.Type() == AiGroundActorType.AAGun)
                    {
                        if (actor.Army() == 1)
                        {                            
                            stat.numberDeadRedAAA ++;
                            stat.blueScore += unitAAAPrice;
                        }
                        else if (actor.Army() == 2)
                        {
                            stat.numberDeadBlueAAA++;
                            stat.redScore += unitAAAPrice;
                        }
                        smpSendMSG.MessageToAll("Уничтожена зенитка [ Red/Blue ]:..." + stat.numberDeadRedAAA.ToString() + " / " + stat.numberDeadBlueAAA.ToString(), "Chat");
                    }                    
                } // null
            }
        } // null
    }
}
stat.redScore, stat.blueScore - no error
other stat. have error
Second stat. element in smpSendMSG.MessageToAll - no error.
I have error on VS, but script work fine in game.
Attached Images
File Type: jpg xxx.jpg (415.0 KB, 9 views)

Last edited by podvoxx; 05-26-2012 at 11:27 AM.
Reply With Quote