コード例 #1
0
 private void HandleEvent_Press(GameObject go, bool state)
 {
     if (state)
     {
         if (this.buildingDescriptionLabel != null)
         {
             this.buildingDescriptionLabel.text = this.Description;
         }
     }
     else if (this.IsDragging)
     {
         if (this.CheckBuildingPositionValid() &&
             BuildingsManager.GetInstance().PayForTheBuilding(this.Building.CoinCostLevel1) && !this.gameSceneCtrl.IsArmageddon)
         {
             GameController gameCtrl = GameObject.Find("GameController")
                                       .GetComponent <GameController>();
             if (gameCtrl != null && gameCtrl.GameType == GameType.PVP)
             {
                 gameCtrl.Client.SendCreateBuilding(this.buildingObj.transform.position, this.Building.BuildingType);
             }
             this.buildingObj.GetComponent <BuildingController>()
             .GetFSM()
             .ChangeState(Building_StateBuilding.Instance());
         }
         else
         {
             BuildingsManager.GetInstance().DestroyBuilding(this.buildingObj);
         }
         this.IsDragging = false;
     }
 }
コード例 #2
0
    public override void Enter(BuildingController entityType)
    {
        tk2dSpriteCollectionData data =
            tk2dSystem.LoadResourceByName <tk2dSpriteCollectionData>(entityType.Building.Race + "BuildingsCollection");

        StringBuilder spriteName = new StringBuilder(string.Empty);

        spriteName.Append(entityType.Building.BuildingType);
        spriteName.Append("_");
        spriteName.Append(entityType.Building.FactionType);
        entityType.SelfSprite.SetSprite(data, spriteName.ToString());

        entityType.GetFSM().ChangeState(Building_StateBuilding.Instance());
    }
コード例 #3
0
    public override void OnEvent(EventData photonEvent)
    {
        base.OnEvent(photonEvent);

        switch (photonEvent.Code)
        {
        //case (byte)1:
        //	Hashtable content = photonEvent.Parameters[ParameterCode.CustomEventContent] as Hashtable;
        //    this.lastMoveEv = (Vector3)content[(byte)1];
        //    this.evCount++;
        //    break;

        case EventCode.PropertiesChanged:
            var data = photonEvent.Parameters[ParameterCode.Properties] as Hashtable;
            this.DebugReturn(DebugLevel.ALL, "got something: " + (data["data"] as string));
            break;

        case EventCode.Join:
            //foreach(System.Collections.Generic.KeyValuePair<byte, object> kv in photonEvent.Parameters)
            //{
            //		Debug.Log(kv.Key + " " + kv.Value);
            //}
            Hashtable content = photonEvent.Parameters[ParameterCode.PlayerProperties] as Hashtable;
            if (content.ContainsKey((byte)255))
            {
                string name = (string)content[(byte)255];
                Debug.Log(name);
                if (!name.Equals(SystemInfo.deviceName) || !this.isCreator && name.Equals(SystemInfo.deviceName))
                {
                    this.gameController.MyFactionType = this.isCreator ? FactionType.Blue : FactionType.Red;
                    this.gameController.GetFSM().ChangeState(GameState_BeforeStartGame.Instance());
                }
            }
            break;

        case EventCode.CreateBuilding:
            HashTable   content1 = photonEvent.Parameters[ParameterCode.CustomEventContent] as HashTable;
            FactionType faction1 = (FactionType)content1[(byte)1];
            if (faction1 != this.gameController.MyFactionType)
            {
                Vector3            pos          = (Vector3)content1[(byte)2];
                BuildingType       buildingType = (BuildingType)content1[(byte)3];
                GameObject         building     = BuildingsManager.GetInstance().CreateNewBuilding(buildingType, faction1, pos);
                BuildingController buildingCtrl = building.GetComponent <BuildingController>();
                buildingCtrl.GetFSM().ChangeState(Building_StateBuilding.Instance());
            }
            break;

        case EventCode.GameOver:
            HashTable   content2 = photonEvent.Parameters[ParameterCode.CustomEventContent] as HashTable;
            FactionType faction2 = (FactionType)content2[(byte)1];
            if (faction2 != this.gameController.MyFactionType)
            {
                this.gameController.ViewController.ShowGameResultView(true);
                Time.timeScale = 0;
            }
            break;

        case EventCode.UpgradeBuilding:
        {
            Hashtable   contentUpgrade = photonEvent.Parameters[ParameterCode.CustomEventContent] as Hashtable;
            FactionType faction3       = (FactionType)contentUpgrade[(byte)1];
            if (faction3 != this.gameController.MyFactionType)
            {
                int        buildingId = (int)contentUpgrade[(byte)2];
                GameObject building   = BuildingsManager.GetInstance().GetBuildingById(buildingId);
                if (building != null)
                {
                    BuildingController buildingCtrl = building.GetComponent <BuildingController>();
                    buildingCtrl.UpgradeBuilding();
                }
            }
        }
        break;

        case EventCode.ReleasePlayerSkill:
        {
            Hashtable   contentPlayerSkill = photonEvent.Parameters[ParameterCode.CustomEventContent] as Hashtable;
            FactionType faction4           = (FactionType)contentPlayerSkill[(byte)1];
            if (faction4 != this.gameController.MyFactionType)
            {
                string     skillName        = (string)contentPlayerSkill[(byte)2];
                GameObject playerSkillPanel = GameObject.Find("PlayerSkillPanel");
                if (playerSkillPanel != null)
                {
                    UIPlayerSkillController playerSkillCtrl =
                        playerSkillPanel.GetComponent <UIPlayerSkillController>();

                    switch (skillName)
                    {
                    case "FireBall":
                    {
                        Vector3 pos = (Vector3)contentPlayerSkill[(byte)3];
                        playerSkillCtrl.ReleaseFireBall(pos, faction4);
                    }
                    break;

                    case "LightningBolt":
                        playerSkillCtrl.ReleaseLightningBolt(faction4);
                        break;

                    case "BraySurgery":
                        playerSkillCtrl.ReleaseBraySurgery(faction4);
                        break;

                    case "Heal":
                        playerSkillCtrl.ReleaseHeal(faction4);
                        break;

                    case "Bloodlust":
                        playerSkillCtrl.ReleaseBloodlust(faction4);
                        break;
                    }
                }
            }
            break;
        }
        }
    }