Пример #1
0
    public void init(TowerTemplate towerTemplate, Vector2Int posInCell)
    {
        if (towerTemplate != null)
        {
            this.tt          = towerTemplate;
            this.atkType     = towerTemplate.tbase.atkType;
            this.mainAtk     = towerTemplate.tbase.mainAtk;
            this.extraAtk    = towerTemplate.tbase.extraAtk;
            this.atkInterval = towerTemplate.tbase.towerModel.atkInterval;
            this.atkRange    = towerTemplate.tbase.towerModel.atkRange;
            this.atkPreTime  = towerTemplate.tbase.towerModel.atkPreTime;
            this.mingzhong   = towerTemplate.tbase.mingzhong;
            //this.tt = towerTemplate;

            for (int i = 0; i < towerTemplate.tbase.skills.Count; i++)
            {
                skillComponent.skills [i]        = new SkillState(towerTemplate.tbase.skills[i].skillId, towerTemplate.tbase.skills[i].skillLevel);
                skillComponent.skillCoolDown [i] = 3000;
            }
        }
        this.posInCell = posInCell;
        Vector2Int posLt = MapManager.getInstance().CellToWorld(posInCell.y, posInCell.x);

        //posLt += new Vector2Int (MapManager.TILE_WIDTH * 5,-MapManager.TILE_HEIGHT * 5);
        posXInt     = posLt.x;
        posYInt     = posLt.y;
        atkCoolDown = 1000;
        atkBhvTimer = 0;

        initialized = true;
    }
Пример #2
0
    public void SetAtkState(eAtkType rType, float rActiveTriggerTime, List <string> rActiveTriggerIndex, float rSwichAtkTime, float crossTime)
    {
        SetAllColUnActive();
        SetState(eState.Atk);


        curAtkKey = Time.time;
        float tempKey = curAtkKey;

        float aimTime = PlayAim(rType.ToString(), crossTime);

        Util.DelayCall(rActiveTriggerTime, () =>
        {
            if (tempKey != curAtkKey)
            {
                return;
            }
            for (int i = 0; i < rActiveTriggerIndex.Count; i++)
            {
                SetColActiveOrUn(rActiveTriggerIndex[i], true);
            }
        });

        Util.DelayCall(rSwichAtkTime, () =>
        {
            if (tempKey != curAtkKey)
            {
                return;
            }

            OnHitEvent = null;
            SetAllColUnActive();
            curAtkState = eAtkState.AtkWait;
        });

        Util.DelayCall(aimTime, () =>
        {
            if (tempKey != curAtkKey)
            {
                return;
            }

            curAtkState = eAtkState.None;
            curAtkType  = eAtkType.None;
        });

        curAtkType = rType;
    }