コード例 #1
0
ファイル: SkillQibing.cs プロジェクト: nCore/sanguozhi
    // 骑兵:2
    public static void Skill_Qibing02(Wujiang wujiang, Coordinates target)
    {
        Dictionary <Coordinates, Wujiang> wujiangExpeditions = BattleGameManager.GetInstance().GetWujiangData().GetWujiangExpeditions();
        Wujiang targetWujiang = wujiangExpeditions[target];

        // 1.伤害
        targetWujiang.OnDamage(3000);
        // 2.移动
        Coordinates c1 = wujiang.GetCoordinates();
        Coordinates c2 = targetWujiang.GetCoordinates();
        int         dx = (c2.HexX - c1.HexX);
        int         dy = (c2.HexY - c1.HexY);

        Coordinates myCoordinates = new Coordinates();

        myCoordinates.SetHexXY(c2.HexX + dx, c2.HexY + dy);
        if (!Skills.CanMoveIn(myCoordinates))
        {
            if (targetWujiang.GetWujiangState() == WujiangState.WujiangState_Dead)
            {
                wujiang.Move(c2);
                return;
            }
            return;
        }
        wujiang.Move(myCoordinates);
    }
コード例 #2
0
    public static void Skill_Qiangbing03(Wujiang wujiang, Coordinates target)
    {
        Dictionary <Coordinates, Wujiang> wujiangExpeditions = BattleGameManager.GetInstance().GetWujiangData().GetWujiangExpeditions();
        Wujiang targetWujiang = wujiangExpeditions[target];

        // 1.伤害
        targetWujiang.OnDamage(5000);
        // 2.移动
        Coordinates c1               = wujiang.GetCoordinates();
        Coordinates c2               = targetWujiang.GetCoordinates();
        int         dx               = (c2.HexX - c1.HexX) * 2;
        int         dy               = (c2.HexY - c1.HexY) * 2;
        Coordinates myCoordinates    = new Coordinates();
        Coordinates otherCoordinates = new Coordinates();

        myCoordinates.SetHexXY(c1.HexX + dx, c1.HexY + dy);
        otherCoordinates.SetHexXY(c2.HexX + dx, c2.HexY + dy);

        if (!Skills.CanMoveIn(myCoordinates))
        {
            return;
        }
        else if (!Skills.CanMoveIn(otherCoordinates))
        {
            targetWujiang.Move(myCoordinates);
        }
        else
        {
            targetWujiang.Move(otherCoordinates);
        }
    }
コード例 #3
0
ファイル: CanvasBattleMenu.cs プロジェクト: nCore/sanguozhi
 void Start()
 {
     mTargetPrefab = Resources.Load(WUJIANG_TARGET) as GameObject;
     mTargetParent = new GameObject("TargetParent");
     mTargetParent.transform.position = new Vector3(0, 0, 0);
     // 第一级菜单监听,显示第二级菜单位置
     for (int i = 0; i < mMenuFirstBtns.Length; i++)
     {
         int index = i;
         mMenuFirstBtns[index].GetComponent <Button>().onClick.AddListener(delegate() {
             if (index == 0)
             {
                 // 隐藏整个菜单(一级菜单)
                 gameObject.SetActive(false);
                 // 待机(目前为移动)
                 mWujiang.Move(BattleGameManager.GetInstance().GetWujiangTransparent().transform.position);
                 mWujiang.Seclet(false);
                 BattleGameManager.GetInstance().GetWujiangTransparent().SetActive(false);
             }
             else if (index == 3)
             {
                 // 显示技能菜单(二级菜单)
                 Vector3 scale     = mMenuFirstBtns[index].transform.lossyScale;
                 Vector2 sizeDelta = mMenuFirstBtns[index].GetComponent <RectTransform>().sizeDelta;
                 mSecondMenu.transform.position = mMenuFirstBtns[index].transform.position + new Vector3(sizeDelta.x * scale.x / 2, sizeDelta.y * scale.y / 2, 0);
                 // 根据武将适性显示技能个数
                 for (int j = 0; j < mMenuSecondBtns.Length; j++)
                 {
                     if (j < mWujiang.mSkills.mSkillNames.Count)
                     {
                         mMenuSecondBtns[j].SetActive(true);
                         mMenuSecondBtns[j].GetComponentInChildren <Text>().text = mWujiang.mSkills.mSkillNames[j];
                         // 根据是否可以释放技能来决定是否只用按钮
                         if (mWujiang.mSkills.mAllTargets[j].Count > 0)
                         {
                             EnabelBtn(mMenuSecondBtns[j]);
                         }
                         else
                         {
                             DisabelBtn(mMenuSecondBtns[j]);
                         }
                     }
                     else
                     {
                         mMenuSecondBtns[j].SetActive(false);
                     }
                 }
             }
             else
             {
                 // 隐藏二级菜单
                 mSecondMenu.GetComponent <RectTransform>().anchoredPosition = new Vector2(1000, 1000);
             }
         });
     }
     // 第二级菜单监听
     for (int i = 0; i < mMenuSecondBtns.Length; i++)
     {
         int index = i;
         mMenuSecondBtns[i].GetComponent <Button>().onClick.AddListener(delegate() {
             // 显示技能能攻击的目标集合
             mSkillIndex = index;
             mTargets    = mWujiang.mSkills.mAllTargets[index];
             mWujiang.SetWujiangState(WujiangState.WujiangState_Prepare_Attack);
             ShowSkillTarget(mTargets);
             gameObject.SetActive(false);
         });
     }
     mSecondMenu.GetComponent <RectTransform>().anchoredPosition = new Vector2(1000, 1000);
 }