Exemple #1
0
    public bool CheckAttack(CreatureStats from, CreatureStats to)
    {
        AttackAction action = from.GetComponent <AttackAction>();

        action.Init(to);
        return(action.Check());
    }
Exemple #2
0
    public override Action CreateInstance(Unit unit)
    {
        AttackAction instance = ScriptableObject.CreateInstance <AttackAction>();

        instance.Init(unit, "Attack");
        return(instance);
    }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        if (MatchSystem.instance.GetActivePlayer() == _creatureStat && MatchSystem.instance.CanAction)
        {
            List <CreatureStats> enemies = MatchSystem.instance.GetAllPlayers()
                                           .Where(x => x != _creatureStat)
                                           .Where(x => x.team != _creatureStat.team).ToList();
            //Debug.LogFormat("AI нашел {0} врагов", enemies.Count);

            if (enemies.Count > 0)
            {
                AIPriority enemy = checkPrority(enemies);
                if (enemy == null)
                {
                    return;
                }

                if (enemy.isAttack)
                {
                    //AttackAction action = new AttackAction(_creatureStat, enemy.enemy);
                    AttackAction action = GetComponent <AttackAction>();
                    action.Init(enemy.enemy);
                    MatchSystem.instance.RunAction(action);
                }
                else
                {
                    //MoveAction action = new MoveAction(_creatureStat, enemy.tail);
                    MoveAction action = GetComponent <MoveAction>();
                    action.Init(enemy.tail);
                    MatchSystem.instance.RunAction(action);
                }
            }
        }
    }
Exemple #4
0
    bool addIntoAttackQueue(AttackAction act)
    {
        if (AttackAction.manaCost[(int)act.type] > GameDataKeeper.GetSingleton().currentMagic)
        {
            //TODO: warning - not enough mana
            return(false);
        }

        GameDataKeeper.GetSingleton().UseMagic(AttackAction.manaCost[(int)act.type]);

        if (actionNow == null)
        {
            actionNow = act;
            actionNow.Init();
            return(true);
        }
        else
        {
            actionNext = act;
            return(true);
        }
    }
    public override void OnClick(Tail obj)
    {
        if (obj.TailType == Tail.TailTypes.Ground)
        {
            MoveAction action = MatchSystem.instance.GetActivePlayer().GetComponent <MoveAction>();
            action.Init(obj);
            MatchSystem.instance.RunAction(action);
        }
        else if (obj.TailType == Tail.TailTypes.Treasure)
        {
            PickTreasureAction action = MatchSystem.instance.GetActivePlayer().GetComponent <PickTreasureAction>();
            action.Init(obj.Treasure);
            MatchSystem.instance.RunAction(action);

            //MatchSystem.instance.RunAction(new PickTreasureAction(null, obj.Treasure));
        }
        else if (obj.TailType == Tail.TailTypes.Character)
        {
            AttackAction action = MatchSystem.instance.GetActivePlayer().GetComponent <AttackAction>();
            action.Init(obj.Creature);
            MatchSystem.instance.RunAction(action);
        }
    }
Exemple #6
0
    private void Attack()
    {
        List <CreatureStats> attackList = new List <CreatureStats>();

        foreach (CreatureStats c in _enemies)
        {
            if (GameHelper.instance.CheckAttack(_creature, c))
            {
                attackList.Add(c);
            }
        }

        if (attackList.Count > 0)
        {
            CreatureStats attack = attackList.First();
            AttackAction  action = GetComponent <AttackAction>();
            action.Init(attack);
            MatchSystem.instance.RunAction(action);
        }
        else
        {
            MatchSystem.instance.RunAction(null);
        }
    }
Exemple #7
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Fire1") && (!this.GetComponent <Slime>().IsFreezed()))
        {
            if (actionNow == null)
            {
                addIntoAttackQueue(new baseAttack_1(this));
            }
            else
            {
                switch (actionNow.type)
                {
                case AttackActionType.Base_1:
                    addIntoAttackQueue(new baseAttack_2(this));
                    break;

                case AttackActionType.Base_2:
                    addIntoAttackQueue(new baseAttack_1(this));
                    break;
                }
            }
        }

        if (Input.GetButtonDown("SpecialAttack") && (!this.GetComponent <Slime>().IsFreezed()))
        {
            switch (GameDataKeeper.GetSingleton().currentForm)
            {
            case SlimeForm.Original:
                addIntoAttackQueue(new SpecialOrigin(this, screenPosX, screenPosY));
                break;

            case SlimeForm.Spring:
                if (SpringBombThrowed == false && (actionNow == null || actionNow.type != AttackActionType.SpecialSpring))
                {
                    SpringBombThrowed = true;
                    addIntoAttackQueue(new SpecialSpring(this));
                }
                else if ((actionNow == null || actionNow.type != AttackActionType.SpecialSpringBoom))
                {
                    SpringBombThrowed = false;
                    addIntoAttackQueue(new SpecialSpringBoom(this));
                }
                break;

            case SlimeForm.Summer:
                addIntoAttackQueue(new SpecialSummer(this, screenPosX, screenPosY));
                break;

            case SlimeForm.Autumn:
                //Use attack action to prevent player open and close autumn ability so quickly.
                addIntoAttackQueue(new SpecialAutumn(this));
                break;

            case SlimeForm.Winter:
                break;

            default:
                break;
            }
        }

        if (
            (this.GetComponent <Slime>().autumnOpened&& (
                 !Input.GetButton("SpecialAttack") ||
                 GameDataKeeper.GetSingleton().currentForm != SlimeForm.Autumn)) &&
            (!this.GetComponent <Slime>().IsFreezed()))
        {
            GetComponent <Slime>().AutumnOff();
        }

        //do attack action
        if (actionNow != null)
        {
            actionNow.Update(Time.deltaTime);

            if (actionNow.isOver() && actionNext != null && (!this.GetComponent <Slime>().IsFreezed()))
            {
                actionNow  = null;
                actionNow  = actionNext;
                actionNext = null;

                actionNow.Init();
            }
            else if (actionNow.isEndCombo())
            {
                actionNow = null;
            }
        }
    }