Пример #1
0
        //Sending unit to drop off resources:
        public void SendUnitToDropOffResources()
        {
            //if there's no drop off building
            if (DropOffBuilding == null)
            {
                FindClosetDropOffBuilding();                  //try to find one:
            }

            if (DropOffBuilding != null)               //if there's a drop off building

            {
                if (GameManager.MultiplayerGame == false)                                                                          //in case it's a singleplayer game:
                {
                    UnitMvt.CheckUnitPathLocal(Vector3.zero, DropOffBuilding.gameObject, UnitMvt.GameMgr.MvtStoppingDistance, -1); //directly send the unit to drop off
                }
                else
                {
                    //if it's a MP game, ask the server to send the unit to drop off
                    MFactionManager.InputActionsVars NewInputAction = new MFactionManager.InputActionsVars();
                    NewInputAction.Source = UnitMvt.netId;

                    NewInputAction.Target = TargetResource.gameObject.GetComponent <NetworkIdentity> ().netId;

                    NewInputAction.InitialPos = transform.position;
                    NewInputAction.TargetPos  = DropOffBuilding.transform.position;

                    UnitMvt.GameMgr.Factions [UnitMvt.FactionID].MFactionMgr.InputActions.Add(NewInputAction);
                }
            }
        }
Пример #2
0
        //Set the target unit to heal.
        public void SetTargetUnit(Unit Target)
        {
            //if it's as single player game.
            if (GameManager.MultiplayerGame == false)
            {
                //directly send the unit to build
                SetTargetUnitLocal(Target);
            }
            else
            {
                //in a case of a MP game
                //and it's the unit belongs to the local player:
                if (GameManager.PlayerFactionID == UnitMvt.FactionID)
                {
                    //ask the server to tell all clients at once that this unit is going to heal a unit

                    MFactionManager.InputActionsVars NewInputAction = new MFactionManager.InputActionsVars();
                    NewInputAction.Source = UnitMvt.netId;

                    NewInputAction.Target = Target.netId;

                    NewInputAction.InitialPos = transform.position;
                    NewInputAction.TargetPos  = Target.transform.position;

                    UnitMvt.GameMgr.Factions [UnitMvt.FactionID].MFactionMgr.InputActions.Add(NewInputAction);
                }
            }
        }
Пример #3
0
        //Set the resource's that the unit will collect from:
        public void SetTargetResource(Resource Target)
        {
            //if it's as single player game.
            if (GameManager.MultiplayerGame == false)
            {
                //directly send the unit to collect
                SetTargetResourceLocal(Target);
            }
            else
            {
                //in a case of a MP game
                //and the unit belongs to the local player:
                if (GameManager.PlayerFactionID == UnitMvt.FactionID)
                {
                    //ask the server to tell all clients at once that this unit is going to resource from this resource:

                    MFactionManager.InputActionsVars NewInputAction = new MFactionManager.InputActionsVars();
                    NewInputAction.Source = UnitMvt.netId;

                    NewInputAction.Target = Target.gameObject.GetComponent <NetworkIdentity> ().netId;

                    NewInputAction.InitialPos = transform.position;
                    NewInputAction.TargetPos  = Target.transform.position;

                    UnitMvt.GameMgr.Factions [UnitMvt.FactionID].MFactionMgr.InputActions.Add(NewInputAction);
                }
            }
        }
Пример #4
0
        public void RemoveUnitFromAPC(int ID)
        {
            if (GameManager.MultiplayerGame == true)               //if this is a MP game and it's the local player:
            {
                if (GameManager.PlayerFactionID == FactionMgr.FactionID)
                {
                    //send the custom action input:
                    MFactionManager.InputActionsVars NewInputAction = new MFactionManager.InputActionsVars();

                    //get the APC netID from the unit APC
                    if (gameObject.GetComponent <Unit> ())
                    {
                        NewInputAction.Source = gameObject.GetComponent <Unit> ().netId;
                    }
                    //get the APC netID from the unit APC
                    else if (gameObject.GetComponent <Building> ())
                    {
                        NewInputAction.Source = gameObject.GetComponent <Building> ().netId;
                    }
                    NewInputAction.CustomAction     = true;
                    NewInputAction.StoppingDistance = ID + 13;                   //12 stands for the invisibility.

                    MFactionMgr.InputActions.Add(NewInputAction);
                }
            }
            else
            {
                //offline game? update the attack type directly:
                RemoveUnitFromAPCLocal(ID);
            }
        }
Пример #5
0
        public void EnableAttackType(int ID)
        {
            if (GameManager.MultiplayerGame == true)               //if this is a MP game and it's the local player:
            {
                if (GameManager.PlayerFactionID == UnitMvt.FactionID)
                {
                    //send the custom action input:
                    MFactionManager.InputActionsVars NewInputAction = new MFactionManager.InputActionsVars();

                    NewInputAction.Source           = UnitMvt.netId;
                    NewInputAction.CustomAction     = true;
                    NewInputAction.StoppingDistance = ID;

                    UnitMvt.MFactionMgr.InputActions.Add(NewInputAction);
                }
            }
            else
            {
                //offline game? update the attack type directly:
                EnableAttackTypeLocal(ID);
            }
        }
Пример #6
0
        public void ToggleInvisibility()
        {
            if (GameManager.MultiplayerGame == true)               //if this is a MP game and it's the local player:
            {
                if (GameManager.PlayerFactionID == UnitMvt.FactionID)
                {
                    //send the custom action input:
                    MFactionManager.InputActionsVars NewInputAction = new MFactionManager.InputActionsVars();

                    NewInputAction.Source           = UnitMvt.netId;
                    NewInputAction.CustomAction     = true;
                    NewInputAction.StoppingDistance = 12.0f;                     //12 stands for the invisibility.

                    UnitMvt.MFactionMgr.InputActions.Add(NewInputAction);
                }
            }
            else
            {
                //offline game? update the attack type directly:
                ToggleInvisibilityLocal();
            }
        }
Пример #7
0
        //add a health to the building.
        public void AddResourceAmount(float Value, GatherResource Source)
        {
            //AddHealthLocal (Value, Source);

            if (GameManager.MultiplayerGame == false)
            {
                AddResourceAmountLocal(Value, Source);
            }
            else
            {
                if (GameManager.PlayerFactionID == Source.UnitMvt.FactionID)                //if it's the local player.
                {
                    //send input action to the MP faction manager if it's a MP game:
                    MFactionManager.InputActionsVars NewInputAction = new MFactionManager.InputActionsVars();
                    NewInputAction.Source           = gameObject.GetComponent <NetworkIdentity>().netId;
                    NewInputAction.Target           = Source.UnitMvt.netId;
                    NewInputAction.StoppingDistance = Value;

                    GameManager.Instance.Factions[Source.UnitMvt.FactionID].MFactionMgr.InputActions.Add(NewInputAction);
                }
            }
        }