Fulqrum Publishing Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official Fulqrum Publishing forum > Fulqrum Publishing > IL-2 Sturmovik: Cliffs of Dover > FMB, Mission & Campaign builder Discussions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 06-07-2011, 07:50 AM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Purchased a book called "Introduction (or basic) course to C# programming" by a university professor last Saturday. It is only about 200 pages and makes things way easier.

Below is a sample code I wrote yesterday after just 2 days of reading it. Of cause I was using 2 pieces of code from other people: ZaltysZ and naryv, but the book provided enough understanding to combine them and finetune to my needs. Just 4 weeks ago I thought C# was beyond my comprehension. Now I think the basics of it are easier than basics of the English language. Do not expect developers include such a book into documentation, just go out and buy one.

Code:
 string[] activeSector = { "D3", "D4" };       // sectors attacked by ground groups
    string[] side = { "хз", "Red", "Blue"};         // army side
    int LastMissionLoaded = 0;
    double initTime;

    string currSide = " ";
    string currSector = " ";

    int missLoaded = 0;                         // debugging 


    public override void Init(maddox.game.ABattle battle, int missionNumber)
    {
        base.Init(battle, missionNumber);
        MissionNumberListener = -1; //Listen to events of every mission

        //Planned missions MissionLoader(int offset, int repeat, string mission)
        MissionLoader(90, -1, "missions/Multi/Dogfight/BoF1/sub/0_1_gg.mis"); // 10s from main mission start and no repeate every -s
        MissionLoader(900, -1, "missions/Multi/Dogfight/BoF1/sub/0_2_gg.mis");
        MissionLoader(300, -1, "missions/Multi/Dogfight/BoF1/sub/1_2_gg.mis");
        MissionLoader(1200, -1, "missions/Multi/Dogfight/BoF1/sub/1_1_gg.mis");
    }

  
	public void MissionLoader(int offset, int repeat, string mission)
	{
		if (offset > 0)
            Timeout(offset, () => { MissionLoader(0, repeat, mission); });
		else
			{
				GamePlay.gpPostMissionLoad(mission);
                // debugging
                //GamePlay.gpHUDLogCenter( side[j].ToString() + " tanks are attacking sector " + activeSector[i].ToString() + "!");

                missLoaded++;
                GamePlay.gpHUDLogCenter(String.Format("Mission {0} loaded.", missLoaded));

                if (repeat > 300 )
                    Timeout(repeat, () => { MissionLoader(0, repeat, mission); });	
			}
	}
    
    public override void OnTrigger(int missionNumber, string shortName, bool active)   
    {
        base.OnTrigger(missionNumber, shortName, active);

        for (int i = 0; i < activeSector.Length ; i++) 
        {
            for (int j = 1; j < side.Length; j++)
            {
                string str = i.ToString() + "_" + (j).ToString() + "_gg";
                if (str.Equals(shortName))                  // checks trigger
                {

                    GamePlay.gpPostMissionLoad("missions\\Multi\\Dogfight\\BoF1\\sub\\" + str + ".mis"); // loads tanks mission

                    //GamePlay.gpHUDLogCenter(side[j].ToString() + " tanks are attacking sector " + activeSector[i].ToString() + "! ***test***");

                    currSide = side[j];
                    currSector = activeSector[i];
                    repeatGroundMsg(90, currSide, currSector);

                    //initTime = 0.0;
                    //Timeout(initTime += 90, () =>
                    //{
                    //    GamePlay.gpHUDLogCenter(currSide.ToString() + " tanks are attacking sector " + currSector.ToString() + "! ***in cycle***");
                    //    //GamePlay.gpHUDLogCenter(addStr + " tanks are attacking sector " + activeSector[i] + "!");
                    //});
                    break;
                }
                
            }
        }

    }


    private void repeatGroundMsg(int delay, string currSide, string currSector)
    {
                    initTime = 0.0;
                    Timeout(initTime += delay, () =>
                    {
                        GamePlay.gpHUDLogCenter(currSide.ToString() + " tanks are attacking sector " + currSector.ToString() + "!"); // is .ToString() necessary here??
                    });

    }
upd.
OT, but as I do not want to start a new thread for this. Can Timeout(initTime += 90, () => be used inside a cycle? Does it prevents a cycle from further execution? I had some problems with triggers when Timeout(initTime += 90, () => was inside the onTrigger cycle. However current code is probably not different in essence from having Timeout(initTime += 90, () => inside the cycle but it works somehow ))

Last edited by Ataros; 06-07-2011 at 08:20 AM.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:11 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.