Пример #1
0
 public override void OnEnter()
 {
     Debug.Log("Enter MoveCameraState");
     camareMng = GameRoot.GetInstance().CameraMng;
     state     = MoveCameraStateFSM.Idle;
     lastSingleTouchPosition = useMouse ? (Vector2)Input.mousePosition : Input.GetTouch(0).position;
 }
Пример #2
0
    public void InjectData(CreatureFightData data)
    {
        _data  = data;
        isAnim = false;
        switch (data.type)
        {
        case 0:
            unitCard.SetActive(true);
            skillCard.SetActive(false);
            constructureCard.SetActive(false);
            unitName.text     = StrUtil.GetText(data.CreatureName);
            unitSprite.sprite = GameRoot.GetInstance().BattleField.assetManager.GetCards(data.icon);
            for (int i = 0; i < stars.Length; ++i)
            {
                stars[i].color = i < data.star ? new Color(1, 1, 1) : new Color(0.3f, 0.3f, 0.3f);
            }
            level.text           = "Lv." + data.level;
            exp.text             = data.exp + "/" + data.expMax;
            expSlider.value      = (float)data.exp / (float)data.expMax;
            hp.text              = Mathf.FloorToInt(data.hp).ToString();
            attack.text          = Mathf.FloorToInt(data.attack).ToString();
            baseAttackFrame.text = StrUtil.GetText(GetAttackRateString(data.base_attack_interval));
            attackRange.text     = Mathf.FloorToInt(data.attack_range).ToString();
            defence.text         = Mathf.FloorToInt(data.defence).ToString();
            reduce.text          = data.defence >= 0?(data.defence * 2f / (100f + data.defence * 2f) * 100f).ToString("F2") + "%":"-" + ((1 - Mathf.Pow((100f - 2f) / 100f, -data.defence)) * 100f).ToString("F2") + "%";
            speed.text           = StrUtil.GetText(GetSpeedString(data.speed));

            notify.SetActive(true);
            isNotify    = true;
            notifyState = -1;
            notify.GetComponent <Text>().text = StrUtil.GetText("点击翻转查看能力");
            //skill data
            int[] skills = data.skills;
            int   num    = skills.Length;
            for (int i = 0; i < skillIcons.Length; ++i)
            {
                skillIcons[i].gameObject.SetActive(false);
            }
            for (int i = 0; i < num; ++i)
            {
                skillIcons[i].gameObject.SetActive(true);
                skillIcons[i].InjectData(GameRoot.GetInstance().BattleField.assetManager.GetSkillData(skills[i]));
            }

            break;

        case 1:
            unitCard.SetActive(false);
            skillCard.SetActive(false);
            constructureCard.SetActive(true);
            constructureName.text   = StrUtil.GetText(data.CreatureName);
            constructureIcon.sprite = GameRoot.GetInstance().BattleField.assetManager.GetIcon(data.icon);
            notify.SetActive(false);
            isNotify = false;
            break;

        case 2:
            break;
        }
    }
Пример #3
0
    public override BattleState OnUpdate()
    {
        int num = GameRoot.GetInstance().Bridge.GetEnemyNum();

        Debug.Log("enemyNum:" + num);
        return(num > 0 ? BattleState.KeepRunning : BattleState.Caster);
    }
Пример #4
0
        private void Start()
        {
            mng = GameRoot.GetInstance().BattleField.assetManager;

            baseSpeed = GameRoot.GetInstance().BattleField.assetManager.GetCreatureData(id).base_speed;
            //init hp bar and side
            if (type != 1)
            {
                sideCircle = gameObject.transform.Find("Circle").gameObject.GetComponent <SpriteRenderer>();
                sideCircle.gameObject.SetActive(true);
                if (side == 1)
                {
                    hpPrefab = GameRoot.GetInstance().BattleField.assetManager.GreenSlider;
                    gameObject.transform.rotation = Quaternion.Euler(0, 0, 0);

                    sideCircle.color = new Color(0.215f, 0.57f, 0.98f, 0.8f);
                }
                else
                {
                    hpPrefab = GameRoot.GetInstance().BattleField.assetManager.RedSlider;
                    gameObject.transform.rotation = Quaternion.Euler(0, 180, 0);

                    shadowPos.y      = 0.01f;
                    sideCircle.color = new Color(0.981f, 0.217f, 0.217f, 0.8f);
                }
            }
            defaultMeshTint = Color.white;
        }
Пример #5
0
        // >>>>>>>>>>>>>>>>>>>> UI
        public void SetHp(float hp, float maxHp, int isHeal)
        {
            if (hpBar == null)
            {
                hpBar = Instantiate(hpPrefab);
                hpBar.GetComponent <RectTransform>().parent = GameRoot.GetInstance().battleGroundUI.GetComponent <RectTransform>();
                //hpBar.GetComponent<RectTransform>().sizeDelta = new Vector2(Mathf.Sqrt(radius)/2*80,22);
                hpBar.transform.localScale = new Vector3(Mathf.Sqrt(radius) / 2, 1, 1) * 3.2f;
                hpBar.SetActive(false);
                GameRoot.GetInstance().CameraMng.UpdateUI += UpdateHpBar;
            }
            hpBar.SetActive(true);
            hpBar.GetComponent <Slider>().value = hp / maxHp;
            hpBarCacheTime = 0;

            if (isHeal == 0)
            {
                //damage
                damageCacheTime = 0.4f;
            }
            else
            {
                //heal
                healCacheTime = 0.4f;
            }
        }
Пример #6
0
        public Vector2Int GetRoomViewId(int _x, int _y)
        {
            GameDataManager mng       = GameRoot.GetInstance().gameDataManager;
            Vector2Int      temId     = GetRoomId(_x, _y);
            int             start_row = 3;
            int             end_row   = 2 + mng.roomRow;
            int             start_col = 3 - (int)(mng.roomCol / 2);
            int             end_col   = 2 + mng.roomCol;

            if (temId.x <= end_row && temId.x >= start_row && temId.y <= end_col && temId.y >= start_col)
            {
                return(temId);
            }
            else
            {
                int boss_room_max_x = 2 * (BattleDef.roomBound + BattleDef.roomInterval);
                int boss_room_max_y = 3 * (BattleDef.roomBound + BattleDef.roomInterval) + (int)0.1 * BattleDef.roomBound;
                int boss_room_min_x = boss_room_max_x - (int)1.2 * BattleDef.roomBound;
                int boss_room_min_y = boss_room_max_y - (int)1.2 * BattleDef.roomBound;
                if (_x <= boss_room_max_x && _x >= boss_room_min_x && _y <= boss_room_max_y && _y >= boss_room_min_y)
                {
                    return(new Vector2Int(2, 3));
                }
            }
            return(Vector2Int.zero);
        }
Пример #7
0
    public void RemoveStructure()
    {
        GameDataManager mng = GameRoot.GetInstance().gameDataManager;

        mng.ChangeRoomConstructure(currRoomId, -1);
        RefreshInfo();
    }
Пример #8
0
    public void OpenPackageCreature(int index)
    {
        if (package == null)
        {
            package = Instantiate(packagePrefab);
            package.transform.parent     = gameObject.transform;
            package.transform.localScale = Vector3.one;
            package.GetComponent <RectTransform>().position = new Vector3(Screen.width * 3 / 2, 0, 0);
        }
        CreatureFightData roomData  = GameRoot.GetInstance().gameDataManager.GetInRoomConstructure(currRoomId);
        PackageUI         packageUI = package.GetComponentInChildren <PackageUI>();

        if (roomData == null)
        {
            return;
        }
        switch (roomData.con_type)
        {
        case 0:
            packageUI.Init(PackageType.IdleCreature, 1);
            package.transform.DOMoveX(Screen.width / 2, 0.3f);
            currIndex = index;
            packageUI.SelectAction += ChangeCreature;
            break;

        case 2:
            packageUI.Init(PackageType.IdlePartTool, 1);
            package.transform.DOMoveX(Screen.width / 2, 0.3f);
            currIndex = index;
            packageUI.SelectAction += ChangeCreature;
            break;
        }
    }
Пример #9
0
    public void Init(PackageType type, int selectNum)
    {
        CleanUp();
        dataList  = new List <CreatureFightData>();
        entities  = new List <GameObject>();
        SelectUid = new List <int>();
        needNum   = selectNum;

        var creatures = GameRoot.GetInstance().gameDataManager.GetPackageList(type);
        //gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(690, height);
        ScrollRect scroll      = gameObject.GetComponentInChildren <ScrollRect>();
        int        creatureNum = creatures.Count;

        scroll.content.sizeDelta = new Vector2(690, Mathf.CeilToInt((float)creatureNum / 5f) * 133 + 13);
        for (int i = 0; i < creatureNum; ++i)
        {
            dataList.Add(creatures[i]);
            int        row    = i / 5;
            int        col    = i - row * 5 + 1;
            GameObject entity = Instantiate(iconPrefab);
            entity.GetComponent <ClickEvent>().clickActionObj += IconClicked;
            entity.transform.parent     = scroll.content.gameObject.transform;
            entity.transform.localScale = Vector3.one;
            entity.GetComponent <RectTransform>().localPosition = new Vector2((col - 1) * 133 + 73, -row * 133 - 73);
            entities.Add(entity);
        }
        RefreshView();
    }
Пример #10
0
 public void OnClick()
 {
     if (state == DungeonUIState.Idle)
     {
         Vector3 point;
         if (BattleDef.useMouse)
         {
             point = Input.mousePosition;
         }
         else
         {
             point = Input.touches[0].position;
         }
         Ray        ray = Camera.main.ScreenPointToRay(point);
         RaycastHit hit;
         Physics.Raycast(ray, out hit);
         int gridX, gridY;
         GameRoot.GetInstance().MapField.GetGridPos(hit.point.x, hit.point.z, out gridX, out gridY);
         if (hit.collider != null)
         {
             Vector2Int id     = GameRoot.GetInstance().MapField.GetRoomViewId(gridX, gridY);
             Vector2Int center = GameRoot.GetInstance().MapField.GetRoomCenter(id.x, id.y);
             Debug.Log("center Pos:" + center);
             int key = id.x * 10 + id.y;
             if (key != 0)
             {
                 state          = DungeonUIState.Strategy;
                 currRoomId     = key;
                 currRoomCenter = center;
                 OpenDungeonInfo();
             }
         }
     }
 }
Пример #11
0
    public void OpenDestination()
    {
        if (skillData == null)
        {
            return;
        }
        List <string> contents = new List <string>();

        contents.Add("<color=#2CFFFFFF><b>" + StrUtil.GetText(skillData.skill_name) + "</b></color>" + ":\n" + StrUtil.GetText(skillData.skill_des));
        for (int i = 0; i < skillData.tips.Length; ++i)
        {
            switch (skillData.tips[i])
            {
            case SkillTip.Energy:
                contents.Add(StrUtil.GetText("<color=#2CFFFFFF><b>力量</b></color>:每层力量提供额外1点攻击力,普通攻击后层数减半"));
                break;

            case SkillTip.Strength:
                contents.Add(StrUtil.GetText("<color=#2CFFFFFF><b>力量</b></color>:每层力量提供额外1点攻击力,普通攻击后层数减半"));
                break;

            case SkillTip.Vampire:
                contents.Add(StrUtil.GetText("<color=#2CFFFFFF><b>吸血</b></color>:每层吸血在攻击时提供1点生命回复,普通攻击后层数减半"));
                break;

            case SkillTip.Weak:
                contents.Add(StrUtil.GetText("<color=#2CFFFFFF><b>虚弱</b></color>:攻击力减少35%,普通攻击后层数减1"));
                break;
            }
        }
        RectTransform tran = gameObject.GetComponent <RectTransform>();

        GameRoot.GetInstance().mainUIMng.OpenTip(contents, tran.position, tran.sizeDelta.x / 2, tran.sizeDelta.y / 2);
    }
Пример #12
0
 public override void OnEnter()
 {
     //GameRoot.BattleStartAction += BattleEnter;
     //GameRoot.BattleStartDelayAction += BattleStart;
     cameraMng = GameRoot.GetInstance().CameraMng;
     uiMng     = GameRoot.GetInstance().battleUI.GetComponent <BattleUIManager>();
 }
Пример #13
0
    public void PrintGoldTips(Vector3 pos, int value)
    {
        GameObject tips = Instantiate(GameRoot.GetInstance().BattleField.assetManager.GoldTips);

        tips.GetComponent <RectTransform>().parent = GameRoot.GetInstance().battleTextUI.GetComponent <RectTransform>();
        tips.SetActive(true);
        tips.GetComponent <Text>().text = "+" + value.ToString();
        Canvas        canvas    = GameRoot.GetInstance().battleTextUI.GetComponent <Canvas>();
        CamaraManager camara    = GameRoot.GetInstance().CameraMng;
        Vector2       screenPos = Camera.main.WorldToScreenPoint(pos);

        tips.transform.position = new Vector3(screenPos.x, screenPos.y, 0);

        MessageEffect effect = new MessageEffect
        {
            effect   = tips,
            uid      = -1,
            duration = 0.6f,
            pos      = pos
        };

        messageCantainer.Add(effect);
        //float scale = camara.minSize / camara.size;
        tips.transform.localScale = Vector3.one;
    }
Пример #14
0
 public void BattleStart()
 {
     inBattle         = true;
     assetMng         = GameRoot.GetInstance().BattleField.assetManager;
     messageCantainer = new List <MessageEffect>();
     effects          = new List <GameObject>();
 }
Пример #15
0
    public void RemoveCreature()
    {
        GameDataManager mng = GameRoot.GetInstance().gameDataManager;

        mng.ChangeRoomSubData(currRoomId, currIndex, -1);
        RefreshInfo();
    }
Пример #16
0
    public void PushMessage(string content, SystemTipType type)
    {
        GameObject obj = Instantiate(messagePrefab);

        obj.transform.parent = GameRoot.GetInstance().MessageUI.transform;
        obj.GetComponent <RectTransform>().position = new Vector3(Screen.width / 2, Screen.height * 3 / 4, 0);
        obj.transform.localScale = Vector3.one;
        switch (type)
        {
        case SystemTipType.Tip:
            obj.GetComponent <Text>().color = new Color(0.51f, 0.93f, 0.56f);
            break;

        case SystemTipType.Warning:
            obj.GetComponent <Text>().color = new Color(0.94f, 0.40f, 0.46f);
            break;
        }
        obj.GetComponent <Text>().text = content;
        for (int i = 0; i < messageCache.Count; ++i)
        {
            messageCache[i].message.GetComponent <RectTransform>().position += new Vector3(0, 35 * ((float)Screen.width / 750f), 0);
        }
        messageCache.Add(new MessageComponent()
        {
            message  = obj,
            timePass = 0,
        });
    }
Пример #17
0
    public void OpenScene(List <int> uiList, Action completedFunc, string sceneName)
    {
        GameObject loading  = Instantiate(LoadingPrefab);
        LoadingUI  uiScript = loading.GetComponent <LoadingUI>();

        loading.transform.parent        = GameRoot.GetInstance().LoadingUI.transform;
        loading.transform.localPosition = Vector3.zero;
        //loading.GetComponent<RectTransform>().position = new Vector3(Screen.width/2, Screen.height, 0);
        loading.transform.localScale = Vector3.one;
        loadingCache.Insert(0, loading);
        GameObject loadingImage = uiScript.loadingImage;

        loadingImage.transform.localScale = Vector3.one * ((float)Screen.height / (float)Screen.width) / (1334f / 750f);
        GameObject siteBand = uiScript.siteBand;
        Text       siteName = uiScript.siteName;

        loadingImage.SetActive(true);
        siteBand.SetActive(false);
        loadingImage.GetComponent <Image>().sprite = loadingSprite;
        siteName.text = StrUtil.GetText(sceneName);

        loadingImage.GetComponent <Image>().color = new Color(0, 0, 0, 0);
        loadingImage.GetComponent <Image>().DOColor(new Color(1, 1, 1, 1), 0.8f).onComplete += () => {
            //loading at here
            HideUI(true);
            sceneFuncList.Add(completedFunc);

            loadingImage.GetComponent <Image>().DOColor(new Color(0, 0, 0, 0), 0.8f).onComplete += () =>
            {
                siteBand.SetActive(true);
                siteBand.GetComponent <Image>().color = new Color(1, 1, 1, 0);
                siteBand.GetComponent <Image>().DOColor(new Color(1, 1, 1, 1), 0.5f).onComplete += () => {
                    siteBand.GetComponent <Image>().DOColor(new Color(1, 1, 1, 1), 2f).onComplete += () =>
                    {
                        siteBand.GetComponent <Image>().DOColor(new Color(1, 1, 1, 0), 0.5f).onComplete += () =>
                        {
                            siteBand.SetActive(false);
                        };
                    };
                };
                siteName.GetComponent <Text>().color = new Color(1, 0.9f, 0.65f, 0);
                siteName.GetComponent <Text>().DOColor(new Color(1, 0.9f, 0.65f, 1), 0.5f).onComplete += () => {
                    siteName.GetComponent <Text>().DOColor(new Color(1, 0.9f, 0.65f, 1), 2f).onComplete += () =>
                    {
                        siteName.GetComponent <Text>().DOColor(new Color(1, 0.9f, 0.65f, 0), 0.5f).onComplete += () => {
                            loadingCache.Remove(loading);
                            Destroy(loading);
                        };
                    };
                };
                foreach (var ui in uiList)
                {
                    OpenUI(ui);
                    ++sceneCache;
                }
                loadingImage.SetActive(false);
            };
        };
    }
Пример #18
0
 public void EnterUnit()
 {
     if (ownScene != null)
     {
         ownScene.EnterScene();
     }
     GameRoot.GetInstance().StartBattle();
 }
Пример #19
0
 public void CleanInfoUI()
 {
     if (cardPrefab != null)
     {
         cardPrefab.SetActive(false);
     }
     GameRoot.GetInstance().InfoUI.SetActive(false);
 }
Пример #20
0
        private void SetTransform(int gridX, int gridY)
        {
            float x = 0f;
            float y = 0f;

            GameRoot.GetInstance().MapField.GetViewPos(gridX, gridY, out x, out y);
            gameObject.transform.position = new Vector3(x, 0, y);
        }
Пример #21
0
 public void Back()
 {
     DOTween.Clear();
     GameRoot.GetInstance().CameraMng.StopSelectHero();
     GameRoot.GetInstance().mainUIMng.CloseScene();
     GameRoot.GetInstance().QuitSelectHero();
     GameRoot.GetInstance().mainUIMng.OpenUI(0);
 }
Пример #22
0
    public void SetPos(int x, int y, float z)
    {
        MapField mapField = GameRoot.GetInstance().MapField;
        float    v_x, v_y;

        mapField.GetViewPos(x, y, out v_x, out v_y);
        gameObject.transform.position = new Vector3(v_x, z, v_y);
    }
Пример #23
0
    public void OnEnter()
    {
        heroData         = GameRoot.GetInstance().BattleField.assetManager.GetHeroData(GameRoot.GetInstance().gameDataManager.boss.id);
        heroName.text    = StrUtil.GetText(heroData.CreatureName);
        exp              = GameRoot.GetInstance().gameDataManager.bossExp[heroData.id - 1001];
        proficiency.text = StrUtil.GetText("熟练度:") + exp;

        heroSprite.sprite = GameRoot.GetInstance().BattleField.assetManager.GetCards(heroData.icon);

        skillPanel.content.sizeDelta = new Vector2(0, 160 * heroData.talents.Length + 20);

        int unlockNum = 0;

        for (int i = 0; i < heroData.talents.Length; ++i)
        {
            SkillData  skillData = GameRoot.GetInstance().BattleField.assetManager.GetSkillData(heroData.talents[i]);
            GameObject obj       = Instantiate(skillInfoPrefab);
            obj.transform.parent        = skillPanel.content.transform;
            obj.transform.localScale    = Vector3.one;
            obj.transform.localPosition = new Vector3(325, -100 - i * 160, 0);
            obj.GetComponent <SkillInfoPanel>().InjectData(skillData, heroData);
            if (skillData.needExp <= exp)
            {
                ++unlockNum;
                obj.GetComponent <SkillInfoPanel>().Lock(false);
            }
            else
            {
                obj.GetComponent <SkillInfoPanel>().Lock(true);
            }
        }

        talent.text = StrUtil.GetText("天赋") + " " + unlockNum + "/" + heroData.talents.Length;

        quitBtn.GetComponent <RectTransform>().position = new Vector3(-Screen.width * 2 / 5, quitBtn.GetComponent <RectTransform>().position.y, 0);
        quitBtn.GetComponent <RectTransform>().DOMoveX(0, 0.5f);
        nextBtn.GetComponent <RectTransform>().position = new Vector3(Screen.width * 3 / 2, quitBtn.GetComponent <RectTransform>().position.y, 0);
        nextBtn.GetComponent <RectTransform>().DOMoveX(Screen.width, 0.5f);
        float x = heroName.gameObject.GetComponent <RectTransform>().position.x;

        heroName.gameObject.GetComponent <RectTransform>().position = new Vector3(-Screen.width * 2 / 5, heroName.GetComponent <RectTransform>().position.y, 0);
        heroName.gameObject.GetComponent <RectTransform>().DOMoveX(x, 0.5f);

        float x_2 = proficiency.gameObject.GetComponent <RectTransform>().position.x;

        proficiency.gameObject.GetComponent <RectTransform>().position = new Vector3(-Screen.width * 2 / 5, proficiency.GetComponent <RectTransform>().position.y, 0);
        proficiency.gameObject.GetComponent <RectTransform>().DOMoveX(x_2, 0.5f);

        float x_3 = talent.gameObject.GetComponent <RectTransform>().position.x;

        talent.gameObject.GetComponent <RectTransform>().position = new Vector3(-Screen.width * 2 / 5, talent.GetComponent <RectTransform>().position.y, 0);
        talent.gameObject.GetComponent <RectTransform>().DOMoveX(x_3, 0.5f);

        float x_4 = skillPanel.gameObject.GetComponent <RectTransform>().position.x;

        skillPanel.gameObject.GetComponent <RectTransform>().position = new Vector3(-Screen.width * 2 / 5, skillPanel.GetComponent <RectTransform>().position.y, 0);
        skillPanel.gameObject.GetComponent <RectTransform>().DOMoveX(x_4, 0.5f);
    }
Пример #24
0
        public void Remove()
        {
            alive = false;

            //GameRoot.GetInstance().PlayerMng.AddSaving(GetSocketPos("S_Center"), 3 - side, (int)(cost * BattleDef.KillEarnFactor));
            GameRoot.GetInstance().MapField.RemoveEntity(this, 0f);
            Destroy(hpBar, 0f);
            Destroy(gameObject, 0f);
        }
Пример #25
0
 public void Next()
 {
     DOTween.Clear();
     GameRoot.GetInstance().CameraMng.StopSelectHero();
     GameRoot.GetInstance().mainUIMng.CloseScene();
     GameRoot.GetInstance().QuitSelectHero();
     GameRoot.GetInstance().gameDataManager.InitGameData();
     GameRoot.GetInstance().mainUIMng.OpenUI(8);
 }
Пример #26
0
    public void AddUnit()
    {
        LuaFunction  func = luaState.GetFunction("add_unit");
        CreatureData data = GameRoot.GetInstance().BattleField.assetManager.GetCreatureData(0);

        func.BeginPCall();
        func.Push(data);
        func.PCall();
        func.EndPCall();
    }
Пример #27
0
 public void LoadGame()
 {
     if (gameDataManager.LoadData() == -1)
     {
         Debug.Log("No Save File");
         return;
     }
     moduleInit();
     GameRoot.GetInstance().mainUIMng.OpenUI(9);
 }
Пример #28
0
    public void GetPos(out int x, out int y, out float z)
    {
        MapField mapField = GameRoot.GetInstance().MapField;
        int      g_x, g_y;

        mapField.GetGridPos(gameObject.transform.position.x, gameObject.transform.position.z, out g_x, out g_y);
        x = g_x;
        y = g_y;
        z = gameObject.transform.position.y;
    }
Пример #29
0
 public void ClickHero(GameObject obj)
 {
     foreach (var s in heroScripts)
     {
         s.SetSelect(false);
     }
     obj.GetComponent <HeroIconUI>().SetSelect(true);
     GameRoot.GetInstance().gameDataManager.ChangeBoss(obj.GetComponent <HeroIconUI>().heroData.id);
     RefreshView(obj.GetComponent <HeroIconUI>().heroData.id);
 }
Пример #30
0
        public static UnitData GetUnitData(int id)
        {
            AssetManager mng;

            mng = GameRoot.GetInstance().BattleField.assetManager;
            CreatureFightData data = new CreatureFightData();

            data.LoadData(mng.GetCreatureData(id));
            return(AssetManager.PackCreatureData(data));
        }