コード例 #1
0
    private void HandleEvent(GameObject eventObj)
    {
        string eventObjTag = eventObj.tag;

        switch (eventObjTag)
        {
        case "HomePageStartGameButton":
        {
            break;
        }

        case "HomePageOptionsButton":
        {
            break;
        }

        case "HomePagePVEButton":
        {
            this.GameController.GameType      = GameType.PVE;
            this.GameController.MyFactionType = FactionType.Blue;
            this.GameController.GetFSM().ChangeState(GameState_BeforeStartGame.Instance());
            break;
        }

        case "HomePagePVPButton":
        {
            this.GameController.GameType = GameType.PVP;
            this.GameController.GetFSM().ChangeState(GameState_Matching.Instance());
            break;
        }

        case "GameResultBackToMenuButton":
        {
            Time.timeScale = 1;
            GameSceneController gameSceneCtrl = GameObject.Find("GameSceneController").GetComponent <GameSceneController>();
            gameSceneCtrl.BackToMainMenu();
            this.GameController.GetFSM().ChangeState(GameState_HomePage.Instance());
            break;
        }
        }
    }
コード例 #2
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;
        }
        }
    }
コード例 #3
0
 public static GameState_BeforeStartGame Instance()
 {
     return(instance ?? (instance = new GameState_BeforeStartGame()));
 }