コード例 #1
0
    private void Start()
    {
        float ratio = (1.2f / 2.81203f) * mycamera.orthographicSize;

        objecMain.transform.localScale = Vector3.one * ratio;
        objectSub.GetComponent <RectTransform>().localScale = Vector3.one * ((0.8f / 2.81203f) * mycamera.orthographicSize);
        left_positon   = _tmpLeft.transform.position;
        right_position = _tmpRight.transform.position;
        left_button1Choice.onClick.AddListener(() => {
            SelfDestruction_hero(_tmpLeft);
            _tmpLeft      = CreateHero(listHero[heroleftchoice], Constant.CHAIR_LEFT);
            _tmpHero_left = _tmpLeft.transform.GetChild(0).GetComponent <BOL_Hero_Controler>();
            BOL_PlaySkill_Controller.instance._Hero_left_ControlSkill = _tmpHero_left;
            //_heroType_left = BOL_Hero_Controler.HeroType.hero1;
            //_tmpHero_left = GetHero(_heroType_left);
            _tmpHero_left.chairPositions = 2;
            Animator_Left = _tmpHero_left.animatorHero;
            _tmpHero_left.InitData();
        });
        right_button1Choice.onClick.AddListener(() => {
            SelfDestruction_hero(_tmpRight);
            _tmpRight      = CreateHero(listHero[herorightchoice], Constant.CHAIR_RIGHT);
            _tmpHero_right = _tmpRight.transform.GetChild(0).GetComponent <BOL_Hero_Controler>();
            BOL_PlaySkill_Controller.instance._Hero_right_ControlSkill = _tmpHero_right;
            //_heroType_right = BOL_Hero_Controler.HeroType.hero1;
            //_tmpHero_right = GetHero(_heroType_right);
            _tmpHero_right.chairPositions = 4;
            Animator_Right = _tmpHero_right.animatorHero;
            _tmpHero_right.InitData();
        });
        StartCoroutine(DoActionInit());
    }
コード例 #2
0
 public void SpawnHeroWhenChoice(int chairID, int heroID)
 {
     Debug.LogWarning("heroID" + heroID);
     if (chairID == Constant.CHAIR_LEFT)
     {
         if (_chairLeftSpawn != null)
         {
             DespawnGameObject(_chairLeftSpawn);
             _chairLeftSpawn = null;
         }
         if (listHero[heroID].heroPrefab == null)
         {
             GameObject abc = Resources.Load("HeroPrefab/" + TypeStringPath[heroID]) as GameObject;
             listHero[heroID].heroPrefab = abc;
         }
         _chairLeftSpawn = LeanPool.Spawn(listHero[heroID].heroPrefab, chairLeft.transform.localPosition, Quaternion.identity);
         _chairLeftSpawn.transform.localScale = new Vector3(0.6f, 0.6f);
         _hero_left = _chairLeftSpawn.transform.GetChild(0).GetComponent <BOL_Hero_Controler>();
         _hero_left.chairPositions = Constant.CHAIR_LEFT;
         BOL_PlaySkill_Controller.instance._Hero_left_ControlSkill = _hero_left;
     }
     else if (chairID == Constant.CHAIR_RIGHT)
     {
         if (_chairRightSpawn != null)
         {
             DespawnGameObject(_chairRightSpawn);
             _chairRightSpawn = null;
         }
         if (listHero[heroID].heroPrefab == null)
         {
             GameObject abc = Resources.Load("HeroPrefab/" + TypeStringPath[heroID]) as GameObject;
             listHero[heroID].heroPrefab = abc;
         }
         _chairRightSpawn = LeanPool.Spawn(listHero[heroID].heroPrefab, chairRight.transform.localPosition, Quaternion.Euler(new Vector3(0, 180)));
         _chairRightSpawn.transform.localScale = new Vector3(0.6f, 0.6f);
         _hero_right = _chairRightSpawn.transform.GetChild(0).GetComponent <BOL_Hero_Controler>();
         _hero_right.chairPositions = Constant.CHAIR_RIGHT;
         BOL_PlaySkill_Controller.instance._Hero_right_ControlSkill = _hero_right;
     }
     else
     {
         //if (_chairRightSpawn != null) {
         //  DespawnGameObject(_chairRightSpawn);
         //  _chairRightSpawn = null;
         //}
         //if (_chairLeftSpawn != null) {
         //  DespawnGameObject(_chairLeftSpawn);
         //  _chairLeftSpawn = null;
         //}
     }
 }
コード例 #3
0
 public void CreateHeroStartGame(int idleft, int idright)
 {
     SelfDestruction_hero(hero_left);
     SelfDestruction_hero(hero_right);
     hero_left  = CreateHeros(Constant.CHAIR_LEFT, idleft, ListHeroPrefab);
     hero_right = CreateHeros(Constant.CHAIR_RIGHT, idright, ListHeroPrefab);
     _hero_left = hero_left.transform.GetChild(0).GetComponent <BOL_Hero_Controler>();
     _hero_left.chairPositions = Constant.CHAIR_LEFT;
     _hero_right = hero_right.transform.GetChild(0).GetComponent <BOL_Hero_Controler>();
     _hero_right.chairPositions = Constant.CHAIR_RIGHT;
     _hero_left.InitData();
     _hero_right.InitData();
     _hero_left.vector_competitor  = _hero_right.myBody.transform.position;
     _hero_right.vector_competitor = _hero_left.myBody.transform.position;
     StartCoroutine(InitFirstDataStart());
 }
コード例 #4
0
    public void ResetShowHeroAndButton()
    {
#if TEST
        Debug.LogWarning("ResetShowHeroAndButton");
#endif

        if (_chairLeftSpawn != null)
        {
            DespawnGameObject(_chairLeftSpawn);
        }
        _hero_left = null;
        if (_chairRightSpawn != null)
        {
            DespawnGameObject(_chairRightSpawn);
        }
        _hero_right = null;
        bOL_PlaySkill_Controller.ResetData();
        bOL_PlaySkill_Controller.InitData();
    }
コード例 #5
0
    public void SpawnHeroWhenChoice(int chairID, int heroID, int sessionId = -1)
    {
#if TEST
        Debug.Log("spawn hero |chairID->" + chairID + "  |hero ID->" + heroID);
#endif
        switch (chairID)
        {
        case Constant.CHAIR_LEFT:
            if (tmpCharacterLeft == heroID)
            {
#if TEST
                Debug.Log("trung characterid left=> không spawn lại hero");
                Debug.Log(tmpCharacterLeft + "    " + heroID);
#endif
            }
            else
            {
                tmpCharacterLeft = heroID;
                if (_chairLeftSpawn != null)
                {
                    DespawnGameObject(_chairLeftSpawn);
                    _chairLeftSpawn = null;
                }
                if (heroID >= 0)
                {
                    if (listHero[heroID].heroPrefab == null)
                    {
                        GameObject heroPref = Resources.Load("HeroPrefab/" + TypeStringPath[heroID]) as GameObject;
                        listHero[heroID].heroPrefab = heroPref;
                    }
                    _chairLeftSpawn = LeanPool.Spawn(listHero[heroID].heroPrefab, chairLeft.transform.position, Quaternion.identity);
                    _chairLeftSpawn.transform.localScale = new Vector3(0.6f, 0.6f);
                    leftAnimator = null;
                    leftAnimator = _chairLeftSpawn.transform.GetChild(0).GetComponent <Animator>();
                    _hero_left   = _chairLeftSpawn.transform.GetChild(0).GetComponent <BOL_Hero_Controler>();
                    _hero_left.chairPositions = Constant.CHAIR_LEFT;
                    BOL_PlaySkill_Controller.instance._Hero_left_ControlSkill = _hero_left;
                }
                else
                {
#if TEST
                    Debug.Log("characterid âm, player đứng dậy, đã xóa hero" + heroID);
#endif
                }
            }
            if (sessionId >= 0)
            {
                for (int i = 0; i < BOL_ShowPlayer_Manager.instance.listUserIngame.Count; i++)
                {
                    if (BOL_ShowPlayer_Manager.instance.listUserIngame[i].sessionId == sessionId)
                    {
                        // BOL_ChoiceHero.instance.btnChoiceChairLeft.txtName.text = BOL_ShowPlayer_Manager.instance.listUserIngame[i].nameShowInGame;
                        BOL_ChoiceHero.instance.btnChoiceChairLeft.txtGold.text         = MyConstant.GetMoneyString(BOL_ShowPlayer_Manager.instance.listUserIngame[i].gold);
                        BOL_ChoiceHero.instance.btnChoiceChairLeft.sessionIdUserInChair = sessionId;
                        break;
                    }
                }
            }
            else
            {
                BOL_ChoiceHero.instance.btnChoiceChairLeft.txtName.text = string.Empty;
                BOL_ChoiceHero.instance.btnChoiceChairLeft.txtGold.text = string.Empty;
            }
            break;

        case Constant.CHAIR_RIGHT:
            if (tmpCharacterRight == heroID)
            {
#if TEST
                Debug.Log("trung characterid right=> không spawn lại hero");
                Debug.Log(tmpCharacterRight + "    " + heroID);
#endif
            }
            else
            {
                tmpCharacterRight = heroID;
                if (_chairRightSpawn != null)
                {
                    DespawnGameObject(_chairRightSpawn);
                    _chairRightSpawn = null;
                }
                if (heroID >= 0)
                {
                    if (listHero[heroID].heroPrefab == null)
                    {
                        GameObject abc = Resources.Load("HeroPrefab/" + TypeStringPath[heroID]) as GameObject;
                        listHero[heroID].heroPrefab = abc;
                    }
                    _chairRightSpawn = LeanPool.Spawn(listHero[heroID].heroPrefab, chairRight.transform.position, Quaternion.Euler(new Vector3(0, 180)));
                    _chairRightSpawn.transform.localScale = new Vector3(0.6f, 0.6f);
                    rightAnimator = null;
                    rightAnimator = _chairRightSpawn.transform.GetChild(0).GetComponent <Animator>();
                    _hero_right   = _chairRightSpawn.transform.GetChild(0).GetComponent <BOL_Hero_Controler>();
                    _hero_right.chairPositions = Constant.CHAIR_RIGHT;
                    BOL_PlaySkill_Controller.instance._Hero_right_ControlSkill = _hero_right;
                }
                else
                {
#if TEST
                    Debug.Log("characterid âm , player đứng dậy, đã xóa hero" + heroID);
#endif
                }
            }
            if (sessionId >= 0)
            {
#if TEST
                Debug.Log("session id right ok =" + sessionId);
#endif
                for (int i = 0; i < BOL_ShowPlayer_Manager.instance.listUserIngame.Count; i++)
                {
                    if (BOL_ShowPlayer_Manager.instance.listUserIngame[i].sessionId == sessionId)
                    {
                        // BOL_ChoiceHero.instance.btnChoiceChairRight.txtName.text = BOL_ShowPlayer_Manager.instance.listUserIngame[i].nameShowInGame;
                        BOL_ChoiceHero.instance.btnChoiceChairRight.txtGold.text         = MyConstant.GetMoneyString(BOL_ShowPlayer_Manager.instance.listUserIngame[i].gold);
                        BOL_ChoiceHero.instance.btnChoiceChairRight.sessionIdUserInChair = sessionId;
                        break;
                    }
                }
            }
            else
            {
#if TEST
                Debug.Log("player đứng dây, session id =" + sessionId);
#endif
                BOL_ChoiceHero.instance.btnChoiceChairRight.txtName.text = string.Empty;
                BOL_ChoiceHero.instance.btnChoiceChairRight.txtGold.text = string.Empty;
            }
            break;
        }
    }