Ejemplo n.º 1
0
    void ChangeTurn()
    {
        if (curUnit)
        {
            curUnit.IsMoveOnRound = true;
        }

        isHeroTurn = !isHeroTurn;
        FightUnitPoint tempUnit = GetCurrentMoveUnit(isHeroTurn);

        if (tempUnit != null)
        {
            SelectUnit(tempUnit);
        }
        else
        {
            if (CheckEndRound())
            {
                ChangeRound();
                SelectUnit(GetCurrentMoveUnit(isHeroTurn));
            }
            else
            {
                ChangeTurn();
            }
        }
    }
Ejemplo n.º 2
0
 public override void Deactivate(object controller)
 {
     gameObject.SetActive(false);
     if (currFightUnit)
     {
         currFightUnit.IsActiveSkillSelected = false;
     }
     skillInfoObj.SetActive(false);
     currFightUnit = null;
 }
Ejemplo n.º 3
0
 public override void Activate(object controller)
 {
     gameObject.SetActive(true);
     currFightUnit         = (FightUnitPoint)controller;
     skillBtn.interactable = !currFightUnit.SkillUsed;
     skillBtn.image.sprite = currFightUnit.Squad.unitInfo.activeSkillIcon;
     skillBtn.onClick.RemoveAllListeners();
     skillBtn.onClick.AddListener(OnSkillBtnClick);
     skillInfoLable.text = GetSkillInfo();
     skillInfoObj.SetActive(false);
 }
Ejemplo n.º 4
0
    bool TryUseSkill(FightUnitPoint targetUnit)
    {
        switch (Squad.unitInfo.activeSkill)
        {
        case UnitInfo.ActiveSkill.Heal:
            if (targetUnit.IsHeroUnit == IsHeroUnit)
            {
                if (targetUnit == this)
                {
                    return(false);
                }
                targetUnit.Squad.CurrentHp += (targetUnit.Squad.unitInfo.unitHp * Squad.unitInfo.healPercent) / 100;
                SkillUsed = true;
                return(true);
            }
            break;

        case UnitInfo.ActiveSkill.Damage:
            if (targetUnit.IsHeroUnit != IsHeroUnit)
            {
                if (targetUnit == this)
                {
                    return(false);
                }
                targetUnit.SetDamage(Squad.unitInfo.damageConst + Squad.unitInfo.damageKoef * DamageDone);
                SkillUsed = true;
                return(true);
            }
            break;

        case UnitInfo.ActiveSkill.AoE:
            int damage = Squad.unitInfo.AoEDamage;
            FightModule.Instance.GetAllUnit().ForEach((FightUnitPoint unit) =>
            {
                if (unit.Squad != null)
                {
                    //на случай если умирает юнит использующий скилл
                    unit.SetDamage(damage);
                }
            });
            SkillUsed = true;
            return(true);

        default:
            Debug.LogError("Что-то пошло не так");
            return(false);
        }
        return(false);
    }
Ejemplo n.º 5
0
 void OnUnitClick(FightUnitPoint unit)
 {
     if (curUnit == null)
     {
         return;
     }
     if (!curUnit.IsHeroUnit)
     {
         return;
     }
     if (curUnit.TryAction(unit))
     {
         ChangeTurn();
     }
 }
Ejemplo n.º 6
0
    public static void MoveAI(FightUnitPoint selectedUnit, List <FightUnitPoint> enemyList, System.Action onMove)
    {
        System.Action waitMove = () =>
        {
            Thread.Sleep(waitTimeMs);
            Threading.Execute(delegate
            {
                selectedUnit.TryAction(enemyList.Find((FightUnitPoint unit) => unit.Squad != null));
                onMove.Invoke();
            });
        };
        Thread waitThread = new Thread(new ThreadStart(waitMove));

        waitThread.Start();
    }
Ejemplo n.º 7
0
 public bool TryAction(FightUnitPoint unitToAction)
 {
     if (unitToAction.Squad == null)
     {
         return(false);
     }
     if (IsActiveSkillSelected)
     {
         return(TryUseSkill(unitToAction));
     }
     if (unitToAction.IsHeroUnit != IsHeroUnit)
     {
         if (unitToAction == this)
         {
             ;
             return(false);
         }
         Attack(unitToAction);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 8
0
    void SelectUnit(FightUnitPoint unitPoint)
    {
        if (!unitPoint)
        {
            return;
        }
        if (curUnit)
        {
            if (curUnit.IsHeroUnit)
            {
                if (view)
                {
                    view.Deactivate(unitPoint);
                }
            }
            curUnit.Mesh.material.color = defaultColor;
        }

        curUnit = unitPoint;

        curUnit.Mesh.material.color = selectedColor;
        if (curUnit.IsHeroUnit)
        {
            if (curUnit.Squad.unitInfo.activeSkill != UnitInfo.ActiveSkill.None)
            {
                if (!view)
                {
                    view = ActiveSkillView.Create(ViewStructHelper.Instance.basePanel);
                }

                view.Activate(unitPoint);
            }
        }
        else
        {
            FightAI.MoveAI(curUnit, heroArmyPoints, ChangeTurn);
        }
    }
Ejemplo n.º 9
0
 void OnMoseOverUnit(FightUnitPoint unit)
 {
     //тут планируется менять указатель на "меч" при наведении на врага
 }
Ejemplo n.º 10
0
 void Attack(FightUnitPoint unitToAttack)
 {
     DamageDone += Squad.Attack;
     unitToAttack.SetDamage(Squad.Attack);
 }