Example #1
0
    public override void PlayDead()
    {
        if (this.dead == true)
        {
            return;
        }

        if (this.animator != null)
        {
            this.animator.SetInteger("State", 0);
        }

        BattleControllor.HeroDead(this);
        this.dead = true;

        Destroy(this.hpBar.gameObject);

        if (this.model == null)
        {
            return;
        }


        this.model.PlayDead();
    }
Example #2
0
    private void TryAttack()
    {
        for (int i = 0; i < skillObjects.Count; i++)
        {
            SkillObject skillObject = (SkillObject)skillObjects[i];

            Vector2 v = BattleUtils.PositionToGrid(skillObject.transform.position);

            ArrayList gameObjects = BattleControllor.GetGameObjectsByPosition(v);

            for (int j = 0; j < gameObjects.Count; j++)
            {
                Charactor c = (Charactor)gameObjects[j];

                if (c.GetType() != this.attackOne.GetType() && c.IsActive() == true)
                {
                    bool  crit   = BattleControllor.Crit(skillConfig.crit);
                    float damage = BattleControllor.Attack(attackOne.GetAttribute(), c.GetAttribute(), skillConfig.demageratio, skillConfig.b, crit);

                    c.ChangeHP(damage, crit);

                    if (c.GetAttribute().hp > 0)
                    {
                        c.PlayAttacked();
                    }
                    else
                    {
                        c.PlayDead();
                    }
                }
            }
        }
    }
Example #3
0
    public bool Pick(Hero hero)
    {
        Attribute attribute = hero.GetAttribute();

        if (itemConfig.addhp > 0)
        {
            float addhp = (-attribute.maxHp * itemConfig.addhp) / 10000;
            hero.ChangeHP(addhp, false);
            hero.PlayEffect(1);

            Follower f = hero.follower;

            while (f != null)
            {
                f.ChangeHP(addhp, false);
                f = f.follower;
            }
        }

        if (itemConfig.addpow > 0)
        {
        }

        if (itemConfig.atk > 0)
        {
        }

        BattleControllor.RemoveItem(this);

        return(true);
    }
Example #4
0
    public void Start()
    {
        if (attackedOne == null)
        {
            ArrayList points = AttRange.GetRangeByAttType(skillConfig.attack_type, this.skillConfig.range, this.attackOne.GetAttribute().volume, this.attackOne.GetPoint(), this.attackOne.GetDirection());

            for (int i = 0; i < points.Count; i++)
            {
                ArrayList gameObjects = BattleControllor.GetGameObjectsByPosition((Vector2)points[i]);

                for (int j = 0; j < gameObjects.Count; j++)
                {
                    Charactor c = (Charactor)gameObjects[j];

                    if (c.IsActive() == true && c.GetType() != attackOne.GetType())
                    {
                        this.attackedOne = c;
                    }
                }
            }
        }

        if (attackedOne != null)
        {
            attackOne.PlayAttack();
        }
        else
        {
            end = true;
        }
    }
Example #5
0
    public override void PlayDead()
    {
        if (this.dead == true)
        {
            return;
        }

        this.dead = true;

        if (this.animator != null)
        {
            this.animator.SetInteger("State", 0);
        }

        if (this.charModel == null)
        {
            return;
        }

        if (this.hpBar != null)
        {
            Destroy(this.hpBar.gameObject);
        }

        BattleControllor.RemoveMonster(this);

        this.charModel.PlayDead();

        StartCoroutine(Remove());
    }
Example #6
0
    void Update()
    {
        if (Constance.SPEC_RUNNING == true)
        {
            CheckSpecState();
        }


        BattleControllor.Update();
    }
Example #7
0
    private void TryNormalAttack()
    {
        if (normalSkillCD > 0)
        {
            normalSkillCD -= Time.deltaTime;
            return;
        }

        if (this.charModel.currentState == CharModel.State.ATTACK)
        {
            return;
        }


        ArrayList points = AttRange.GetRangeByAttType(normalAttackSkill.attack_type, this.normalAttackSkill.range, this.attribute.volume, this.position, this.currentDirection);

        for (int i = 0; i < points.Count; i++)
        {
            ArrayList gameObjects = BattleControllor.GetGameObjectsByPosition((Vector2)points[i]);

            for (int j = 0; j < gameObjects.Count; j++)
            {
                Charactor c = (Charactor)gameObjects[j];

                if (c.IsActive() == false)
                {
                    continue;
                }

                if (normalAttackSkill.target > 2)
                {
                    if (c.GetType() == this.GetType())
                    {
                        normalSkillCD = normalAttackSkill.cd;

                        normalAttackSkill.crit = attribute.crit;
                        SkillManager.PlaySkill(this, normalAttackSkill, c);
                        return;
                    }
                }
                else
                {
                    if (c.GetType() != this.GetType())
                    {
                        normalSkillCD = normalAttackSkill.cd;

                        normalAttackSkill.crit = attribute.crit;
                        SkillManager.PlaySkill(this, normalAttackSkill, c);
                        return;
                    }
                }
            }
        }
    }
Example #8
0
    private void TryPickUpItem()
    {
        ArrayList items = BattleControllor.GetItemByPoint(this.position);

        foreach (Item item in items)
        {
            if (this.position == item.GetPoint())
            {
                item.Pick(this);
            }
        }
    }
Example #9
0
    public void Update()
    {
        if (Constance.SPEC_RUNNING == false && Constance.RUNNING == false)
        {
            return;
        }
        else if (Constance.SPEC_RUNNING == true && this.specSign == false)
        {
            return;
        }


        if (attackOne.IsActive() == false)
        {
            this.end = true;
            return;
        }


        if (this.end == true)
        {
            return;
        }

        if (this.attackOne.IsInAttIndex() == false)
        {
            return;
        }

        bool  crit   = BattleControllor.Crit(skillConfig.crit);
        float damage = BattleControllor.Attack(attackOne.GetAttribute(), attackedOne.GetAttribute(), skillConfig.demageratio, skillConfig.b, crit);

        attackedOne.ChangeHP(damage, crit);

        if (attackedOne.GetAttribute().hp > 0)
        {
            attackedOne.PlayAttacked();
        }
        else
        {
            attackedOne.PlayDead();
        }


        attackOne.audio.clip = Resources.Load <AudioClip>("Audio/Skill/7");
        if (attackOne.audio.clip != null)
        {
            attackOne.audio.Play();
        }

        end = true;
    }
Example #10
0
    private void UpdatePosition()
    {
        int x = (int)Mathf.Round(this.transform.localPosition.x / Constance.GRID_GAP);
        int y = -(int)Mathf.Round(this.transform.localPosition.y / Constance.GRID_GAP);

        if (x != this.position.x || y != this.position.y)
        {
            this.position.x = x;
            this.position.y = y;

            BattleControllor.UpdatePosition(this, this.position, this.attribute.volume);
        }
    }
Example #11
0
    private IEnumerator Remove()
    {
        yield return(new WaitForSeconds(1.5f));

        Destroy(this.gameObject);

        if (this.dropItemId != null)
        {
            if (Random.Range(0, 10000) < this.dropOdds)
            {
                BattleControllor.AddItem(this.dropItemId, this.transform.localPosition);
            }
        }
    }
Example #12
0
    public override void PlayDead()
    {
        if (this.dead == true)
        {
            return;
        }

        if (this.animator != null)
        {
            this.animator.SetInteger("State", 0);
        }

        dead = true;

        Follower f = this;

        while (f.follower != null)
        {
            f.follower.followIndex -= 1;
            f = f.follower;
        }

        if (this.prev is Hero)
        {
            ((Hero)this.prev).follower = this.follower;
        }
        else if (this.prev is Follower)
        {
            ((Follower)this.prev).follower = this.follower;
        }

        if (this.follower != null)
        {
            this.follower.prev = this.prev;
        }

        this.state = FollowState.DEAD;
        BattleControllor.RemoveFollower(this);

        if (this.model == null)
        {
            return;
        }

        this.model.PlayDead();

        StartCoroutine(Remove());
    }
Example #13
0
    private void UpdatePosition()
    {
        int x = (int)Mathf.Round(this.transform.localPosition.x / Constance.GRID_GAP);
        int y = -(int)Mathf.Round(this.transform.localPosition.y / Constance.GRID_GAP);

        if (x != this.position.x || y != this.position.y)
        {
            this.position.x = x;
            this.position.y = y;

            BattleControllor.UpdatePosition(this, this.position);

            FindFollower();
            TryPickUpItem();
        }
    }
Example #14
0
    private void FindFollower()
    {
        ArrayList followers = BattleControllor.GetFollowersByPoint(this.position);

        if (followers == null)
        {
            return;
        }

        foreach (Follower follower in followers)
        {
            if (follower.state == FollowState.IDEL)
            {
                follower.SetFollowTarget(this);
            }
        }
    }
Example #15
0
    public override void ChangeHP(float hp, bool crit)
    {
        this.attribute.hp -= hp;

        if (this.attribute.hp > this.attribute.maxHp)
        {
            this.attribute.hp = this.attribute.maxHp;
        }

        this.hpBar.SetHP(this.attribute.hp / this.attribute.maxHp);

        if (this.attribute.hp <= 0)
        {
            BattleControllor.HeroDead(this);
        }

        this.effectObject.PlayNum((int)hp, crit);
    }
Example #16
0
    void Update()
    {
        this.spriteRenderer.sortingOrder = -(int)(this.transform.localPosition.y * 10);

        int x = (int)Mathf.Round(this._transform.localPosition.x / Constance.GRID_GAP);
        int y = -(int)Mathf.Round(this._transform.localPosition.y / Constance.GRID_GAP);

        if (x != this.position.x || y != this.position.y)
        {
            this.position.x = x;
            this.position.y = y;

            BattleControllor.UpdatePosition(this, this.position);
        }


        if (this.dead == true)
        {
            return;
        }

        UpdateState();
        TryAttak();
    }
Example #17
0
    public PointFlyAttackSkill(Charactor attackOne, SkillConfig skillConfig)
    {
        this.attackOne = attackOne;

        ArrayList points = AttRange.GetRangeByAttType(skillConfig.attack_type, skillConfig.range, attackOne.GetAttribute().volume, attackOne.GetPoint(), attackOne.GetDirection());

        for (int i = 0; i < points.Count; i++)
        {
            ArrayList objects = BattleControllor.GetGameObjectsByPosition((Vector2)points[i]);

            for (int j = 0; j < objects.Count; j++)
            {
                Charactor c = objects[j] as Charactor;

                if (c.GetType() != this.attackOne.GetType() && c.IsActive() == true)
                {
                    this.attackedOne = objects[j] as Charactor;
                    break;
                }
            }
        }

        if (attackedOne == null)
        {
            this.end = true;
            return;
        }

        this.attackTransfrom   = this.attackOne.transform;
        this.attackedTransfrom = this.attackedOne.transform;

        this.skillConfig = skillConfig;

        attackOff   = new Vector3((attackOne.GetAttribute().volume / 2.0f - 0.5f) * Constance.GRID_GAP, (attackOne.GetAttribute().volume / 2.0f - 0.5f) * Constance.GRID_GAP, 0);
        attackedOff = new Vector3((attackedOne.GetAttribute().volume / 2.0f - 0.5f) * Constance.GRID_GAP, (attackedOne.GetAttribute().volume / 2.0f - 0.5f) * Constance.GRID_GAP, 0);
    }
Example #18
0
    private bool MoveAble()
    {
        switch (this.currentDirection)
        {
        case MoveDirection.DOWN:

            Vector2 v = nextPathPoint.point;
            v.y = v.y + this.attribute.volume - 1;

            for (int i = 0; i < this.attribute.volume; i++)
            {
                v.x = v.x + i;

                if (BattleControllor.IsMoveable(v) == false)
                {
                    return(false);
                }

                if (BattleControllor.GetGameObjectsByPosition(v).Count > 0)
                {
                    return(false);
                }
            }
            break;

        case MoveDirection.UP:

            v = nextPathPoint.point;

            for (int i = 0; i < this.attribute.volume; i++)
            {
                v.x = v.x + i;

                if (BattleControllor.IsMoveable(v) == false)
                {
                    return(false);
                }

                if (BattleControllor.GetGameObjectsByPosition(v).Count > 0)
                {
                    return(false);
                }
            }
            break;


        case MoveDirection.LEFT:

            v = nextPathPoint.point;

            for (int i = 0; i < this.attribute.volume; i++)
            {
                v.y = v.y + i;

                if (BattleControllor.IsMoveable(v) == false)
                {
                    return(false);
                }

                if (BattleControllor.GetGameObjectsByPosition(v).Count > 0)
                {
                    return(false);
                }
            }

            break;


        case MoveDirection.RIGHT:

            v   = nextPathPoint.point;
            v.x = v.x + this.attribute.volume - 1;

            for (int i = 0; i < this.attribute.volume; i++)
            {
                v.y = v.y + i;

                if (BattleControllor.IsMoveable(v) == false)
                {
                    return(false);
                }

                if (BattleControllor.GetGameObjectsByPosition(v).Count > 0)
                {
                    return(false);
                }
            }

            break;
        }


        return(true);
    }
Example #19
0
    public void Update()
    {
        if (Constance.SPEC_RUNNING == false && Constance.RUNNING == false)
        {
            return;
        }
        else if (Constance.SPEC_RUNNING == true && this.specSign == false)
        {
            return;
        }


        if (end == true)
        {
            return;
        }

        singTime -= Time.deltaTime;

        if (singTime > 0)
        {
            return;
        }

        while (alertBlocks.Count > 0)
        {
            GameObject gameObject = alertBlocks[0] as GameObject;
            MonoBehaviour.Destroy(gameObject);

            alertBlocks.RemoveAt(0);
        }


        if (this.attackOne.IsInAttIndex() == true && attacked == false)
        {
            Attribute attribute = attackOne.GetAttribute();

            GameObject gameObject = (GameObject)MonoBehaviour.Instantiate(SkillObject_pre);

            skillObject      = gameObject.GetComponent <SkillObject>();
            skillObject.res  = 6;
            skillObject.loop = 1;
            skillObject.spriteAnimation.renderer.sortingLayerID = 3;
            skillObject.transform.position = attackOne.transform.localPosition;
            skillObject.sound = 5;

            skillObject.transform.localScale = new Vector2(skillConfig.range / 16f, attribute.volume / 4f);

            switch (attackOne.GetDirection())
            {
            case MoveDirection.DOWN:
                skillObject.SetSpriteEulerAngles(new Vector3(0, 0, 270));
                skillObject.transform.position += new Vector3(0, -0.2f, 0);
                break;

            case MoveDirection.UP:
                skillObject.SetSpriteEulerAngles(new Vector3(0, 0, 90));
                skillObject.transform.position += new Vector3(0, 0.2f, 0);
                break;

            case MoveDirection.LEFT:
                skillObject.SetSpriteEulerAngles(new Vector3(0, 0, 180));
                skillObject.transform.position += new Vector3(-0.2f, 0.2f, 0);
                break;

            case MoveDirection.RIGHT:
                skillObject.transform.position += new Vector3(0.2f, 0.2f, 0);
                break;
            }


            for (int i = 0; i < range.Count; i++)
            {
                ArrayList objects = BattleControllor.GetGameObjectsByPosition((Vector2)range[i]);

                for (int j = 0; j < objects.Count; j++)
                {
                    Charactor c = objects[j] as Charactor;

                    if (c.GetType() != this.attackOne.GetType() && c.IsActive() == true)
                    {
                        bool  crit   = BattleControllor.Crit(skillConfig.crit);
                        float damage = BattleControllor.Attack(attackOne.GetAttribute(), c.GetAttribute(), skillConfig.demageratio, skillConfig.b, crit);

                        c.ChangeHP(damage, crit);

                        if (c.GetAttribute().hp > 0)
                        {
                            c.PlayAttacked();
                        }
                        else
                        {
                            c.PlayDead();
                        }
                    }
                }
            }

            attacked = true;
        }

        if (attacked == false)
        {
            return;
        }


        if (skillObject.IsSpritePlayEnd() == true)
        {
            MonoBehaviour.Destroy(skillObject.gameObject);
            this.attackOne.SetPlayLock(false);
            end = true;
        }
    }
Example #20
0
    public void Update()
    {
        if (Constance.SPEC_RUNNING == false && Constance.RUNNING == false)
        {
            return;
        }
        else if (Constance.SPEC_RUNNING == true && this.specSign == false)
        {
            return;
        }


        if (this.end == true)
        {
            return;
        }


        if (attackedOne.IsActive() == true)
        {
            targetPoint = attackedTransfrom.position + attackedOff;
        }

        if (skillObject == null && this.attackOne.IsInAttIndex())
        {
            if (attackOne.IsActive() == false)
            {
                end = true;
                return;
            }

            GameObject gameObject = (GameObject)MonoBehaviour.Instantiate(SkillObject_pre);

            skillObject = gameObject.GetComponent <SkillObject>();
            skillObject.spriteAnimation.renderer.sortingLayerID = 3;
            skillObject.res = skillConfig.res;
            skillObject.transform.position = attackOne.transform.position + attackOff;

            skillTransfrom = skillObject.transform;

            skillTransfrom.eulerAngles = new Vector3(0, 0, GetAngle());
        }

        if (skillObject == null)
        {
            return;
        }

        float d1 = Time.deltaTime * speed;
        float d2 = Vector3.Distance(skillTransfrom.position, targetPoint);


        if (d1 > d2)
        {
            MonoBehaviour.Destroy(this.skillObject.gameObject);
            this.end = true;

            bool  crit   = BattleControllor.Crit(skillConfig.crit);
            float damage = BattleControllor.Attack(attackOne.GetAttribute(), attackedOne.GetAttribute(), skillConfig.demageratio, skillConfig.b, crit);

            attackedOne.ChangeHP(damage, crit);

//			if(skillConfig.sound2 != 0){
//				AudioClip ac = Resources.Load<AudioClip>("Audio/Skill/" + skillConfig.sound2);
//				attackedOne.audio.clip = ac;
//				attackedOne.audio.Play();
//			}

            if (attackedOne.GetAttribute().hp > 0)
            {
                attackedOne.PlayAttacked();
            }
            else
            {
                attackedOne.PlayDead();
            }

            return;
        }

        skillTransfrom.eulerAngles = new Vector3(0, 0, GetAngle());
        skillTransfrom.position    = Vector3.MoveTowards(skillTransfrom.position, targetPoint, d1);
    }
    public void Update()
    {
        if (Constance.SPEC_RUNNING == false && Constance.RUNNING == false)
        {
            return;
        }
        else if (Constance.SPEC_RUNNING == true && this.specSign == false)
        {
            return;
        }

        if (this.end == true)
        {
            return;
        }

        singTime -= Time.deltaTime;

        if (singTime > 0)
        {
            return;
        }



        while (alertBlocks.Count > 0)
        {
            GameObject gameObject = alertBlocks[0] as GameObject;
            MonoBehaviour.Destroy(gameObject);

            alertBlocks.RemoveAt(0);
        }



        if (attackOne.IsInAttIndex() == true && attacked == false)
        {
            Attribute attribute = attackOne.GetAttribute();
            beginPosition = attackOne.transform.position + attackOff;


            for (int i = 0; i < directions.Count; i++)
            {
                MoveDirection dirction = (MoveDirection)directions[i];

                GameObject gameObject = (GameObject)MonoBehaviour.Instantiate(SkillObject_pre);
                gameObject.transform.localScale = new Vector3(attribute.volume / 4f, attribute.volume / 4f, 0);

                SkillObject skillObject = gameObject.GetComponent <SkillObject>();
                skillObject.res = this.skillConfig.res;
                if (this.specSign == true)
                {
                    skillObject.spriteAnimation.renderer.sortingLayerID = 7;
                }
                else
                {
                    skillObject.spriteAnimation.renderer.sortingLayerID = 1;
                }

                skillObject.transform.position = attackOne.transform.position + attackOff;

                switch (dirction)
                {
                case MoveDirection.DOWN:
                    skillObject.SetSpriteEulerAngles(new Vector3(0, 0, 270));
                    break;

                case MoveDirection.UP:
                    skillObject.SetSpriteEulerAngles(new Vector3(0, 0, 90));
                    break;

                case MoveDirection.LEFT:
                    skillObject.SetSpriteOff(new Vector2(0, 0.15f));
                    skillObject.gameObject.transform.localScale += new Vector3(-skillObject.gameObject.transform.localScale.x * 2, 0, 0);
                    break;

                case MoveDirection.RIGHT:
                    skillObject.SetSpriteOff(new Vector2(0, 0.15f));
                    break;
                }

                skillObjects.Add(skillObject);
            }

            attacked = true;
        }

        if (attacked == false)
        {
            return;
        }


        for (int i = 0; i < skillObjects.Count; i++)
        {
            SkillObject   skillObject = (SkillObject)skillObjects[i];
            MoveDirection direction   = (MoveDirection)directions[i];

            if (skillObject == null)
            {
                continue;
            }

            if (Vector3.Distance(beginPosition, skillObject.transform.position) > distance)
            {
                MonoBehaviour.Destroy(skillObject.gameObject);
                skillObjects[i] = null;
                continue;
            }


            float d1 = Time.deltaTime * speed;

            Vector3 newPosition = Vector3.zero;

            switch (direction)
            {
            case MoveDirection.DOWN:
                newPosition = skillObject.transform.position + new Vector3(0, -d1, 0);
                break;

            case MoveDirection.UP:
                newPosition = skillObject.transform.position + new Vector3(0, d1, 0);
                break;

            case MoveDirection.LEFT:
                newPosition = skillObject.transform.position + new Vector3(-d1, 0, 0);
                break;

            case MoveDirection.RIGHT:
                newPosition = skillObject.transform.position + new Vector3(d1, 0, 0);
                break;
            }

            bool inNewGrid = false;

            if (BattleUtils.PositionToGrid(newPosition) != BattleUtils.PositionToGrid(skillObject.transform.position))
            {
                //in diffrenet grid
                inNewGrid = true;
            }

            skillObject.transform.position = newPosition;

            if (inNewGrid == false)
            {
                continue;
            }


            //Try attack
            Vector2 v = BattleUtils.PositionToGrid(skillObject.transform.position);

            ArrayList objects     = BattleControllor.GetGameObjectsByPosition(v);
            Charactor attackedOne = null;

            for (int j = 0; j < objects.Count; j++)
            {
                Charactor c = objects[j] as Charactor;

                if (c.GetType() != this.attackOne.GetType() && c.IsActive() == true)
                {
                    attackedOne = c;
                    break;
                }
            }


            if (attackedOne != null)
            {
                bool  crit   = BattleControllor.Crit(skillConfig.crit);
                float damage = BattleControllor.Attack(attackOne.GetAttribute(), attackedOne.GetAttribute(), skillConfig.demageratio, skillConfig.b, crit);

                attackedOne.ChangeHP(damage, crit);

                if (attackedOne.GetAttribute().hp > 0)
                {
                    attackedOne.PlayAttacked();
                }
                else
                {
                    attackedOne.PlayDead();
                }

                return;
            }
        }


        for (int i = 0; i < skillObjects.Count; i++)
        {
            if (skillObjects[i] != null)
            {
                return;
            }
        }

        end = true;
    }
    public void Update()
    {
        if (Constance.SPEC_RUNNING == false && Constance.RUNNING == false)
        {
            return;
        }
        else if (Constance.SPEC_RUNNING == true && this.specSign == false)
        {
            return;
        }

        if (end == true)
        {
            return;
        }


        if (this.attackOne.IsInAttIndex() == true && attacked == false)
        {
            Vector2 v = BattleUtils.PositionToGrid(attackOne.transform.position.x, attackOne.transform.position.y);

            Attribute attribute = attackOne.GetAttribute();

            MoveDirection direction = attackOne.GetDirection();

            ArrayList range = AttRange.GetRangeByAttType(skillConfig.attack_type, skillConfig.range, attribute.volume, v, direction);

            GameObject gameObject = (GameObject)MonoBehaviour.Instantiate(SkillObject_pre);

            skillObject      = gameObject.GetComponent <SkillObject>();
            skillObject.res  = this.skillConfig.res;
            skillObject.loop = 1;

            skillObject.transform.position = attackOne.transform.position;

            switch (direction)
            {
            case MoveDirection.DOWN:
                skillObject.SetSpriteEulerAngles(new Vector3(0, 0, 270));
                break;

            case MoveDirection.UP:
                skillObject.SetSpriteEulerAngles(new Vector3(0, 0, 90));
                break;

            case MoveDirection.LEFT:
                skillObject.SetSpriteEulerAngles(new Vector3(0, 0, 180));
                break;

            case MoveDirection.RIGHT:
                break;
            }


            for (int i = 0; i < range.Count; i++)
            {
                ArrayList objects = BattleControllor.GetGameObjectsByPosition((Vector2)range[i]);

                for (int j = 0; j < objects.Count; j++)
                {
                    Charactor c = objects[j] as Charactor;

                    if (c.GetType() != this.attackOne.GetType() && c.IsActive() == true)
                    {
                        bool  crit   = BattleControllor.Crit(skillConfig.crit);
                        float damage = BattleControllor.Attack(attackOne.GetAttribute(), c.GetAttribute(), skillConfig.demageratio, skillConfig.b, crit);

                        c.ChangeHP(damage, crit);

                        if (c.GetAttribute().hp > 0)
                        {
                            c.PlayAttacked();
                        }
                        else
                        {
                            c.PlayDead();
                        }
                    }
                }
            }

            attacked = true;
        }

        if (attacked == false)
        {
            return;
        }



        if (skillObject.IsSpritePlayEnd() == true)
        {
            MonoBehaviour.Destroy(skillObject.gameObject);

            end = true;
        }
    }
Example #23
0
    public void Update()
    {
        if (Constance.SPEC_RUNNING == false && Constance.RUNNING == false)
        {
            return;
        }
        else if (Constance.SPEC_RUNNING == true && this.specSign == false)
        {
            return;
        }

        if (end == true)
        {
            return;
        }


        singTime -= Time.deltaTime;

        if (singTime > 0)
        {
            return;
        }


        while (alertBlocks.Count > 0)
        {
            GameObject gameObject = alertBlocks[0] as GameObject;
            MonoBehaviour.Destroy(gameObject);

            alertBlocks.RemoveAt(0);
        }



        if (this.attackOne.IsInAttIndex() == true && attacked == false)
        {
            Attribute attribute = attackOne.GetAttribute();

            for (int i = 0; i < range.Count; i++)
            {
                GameObject gameObject = (GameObject)MonoBehaviour.Instantiate(SkillObject_pre);

                SkillObject skillObject = gameObject.GetComponent <SkillObject>();
                skillObject.res  = 8;
                skillObject.loop = 1;
                skillObject.transform.localScale = new Vector3(0.5f, 0.5f, 0);

                skillObject.sound = 2;

                skillObject.transform.position = BattleUtils.GridToPosition((Vector2)range[i]);

                skillObjects.Add(skillObject);

                ArrayList objects = BattleControllor.GetGameObjectsByPosition((Vector2)range[i]);

                for (int j = 0; j < objects.Count; j++)
                {
                    Charactor c = objects[j] as Charactor;

                    if (c.GetType() != this.attackOne.GetType() && c.IsActive() == true)
                    {
                        bool  crit   = BattleControllor.Crit(skillConfig.crit);
                        float damage = BattleControllor.Attack(attackOne.GetAttribute(), c.GetAttribute(), skillConfig.demageratio, skillConfig.b, crit);

                        c.ChangeHP(damage, crit);


                        if (c.GetAttribute().hp > 0)
                        {
                            c.PlayAttacked();
                        }
                        else
                        {
                            c.PlayDead();
                        }
                    }
                }
            }

            attacked = true;
        }

        if (attacked == false)
        {
            return;
        }

        if (attacked == false)
        {
            return;
        }

        for (int i = 0; i < skillObjects.Count; i++)
        {
            SkillObject skillObject = skillObjects[i] as SkillObject;

            if (skillObject.IsSpritePlayEnd() == true)
            {
                MonoBehaviour.Destroy(skillObject.gameObject);

                skillObjects.Remove(skillObjects);

                end = true;
                this.attackOne.SetPlayLock(false);
            }
        }
    }
Example #24
0
    private void TryMove()
    {
        if (Constance.RUNNING == false)
        {
            return;
        }

        if (this.running == false)
        {
            return;
        }

        this.nextPosition = GetNextPosition();

        Vector2 nextPoint = BattleUtils.PositionToGrid(this.nextPosition.x, this.nextPosition.y);


        if (BattleControllor.IsMoveable(nextPoint) == false)
        {
            if (this.currentDirection != this.direction)
            {
                this.currentDirection = this.direction;

                if (this.follower != null)
                {
                    follower.SetNextPosition(this._transform.localPosition);
                }
            }
            return;
        }

        //下个格子中的物体
        ArrayList monsterList = BattleControllor.GetMonstersByPoint(nextPoint);

        if (this.position != nextPoint && monsterList.Count > 0)
        {
            //前方有障碍物 需要停止

            if (this.currentDirection != this.direction)
            {
                this.currentDirection = this.direction;

                if (this.follower != null)
                {
                    follower.SetNextPosition(this._transform.localPosition);
                }
            }

            return;
        }


        float moveDistance = Time.deltaTime * speed;

        if (this.currentDirection != this.direction)
        {
            this.currentDirection = this.direction;

            if (this.follower != null)
            {
                follower.SetNextPosition(this._transform.localPosition);
            }
        }


        Move(moveDistance);


        if (follower != null)
        {
            follower.Move(moveDistance);
        }
    }