Ejemplo n.º 1
0
        private void Update()
        {
            if (isAttack)
            {
                attackTimer += Time.deltaTime;
                if (attackTimer >= animationAsset.attackAnimLength)
                {
                    isAttack    = false;
                    attackTimer = 0f;
                }
            }
            else if (isDeath)
            {
                deathTimer += Time.deltaTime;
                if (deathTimer >= animationAsset.deathAnimLength)
                {
                    deathTimer = animationAsset.deathAnimLength;
                }
            }

            //更新数据
            soldierDataBlock.moveSpeedRate[0] = moveSpeed;
            soldierDataBlock.atkTimer[0]      = attackTimer;
            soldierDataBlock.deathTimer[0]    = deathTimer;
            soldierDataBlock.isAttack[0]      = isAttack ? 1f : 0f;
            soldierDataBlock.isDeath[0]       = isDeath ? 1f : 0f;

            //更新绘制
            soldierDataBlock?.UpdateRenderer();
        }
Ejemplo n.º 2
0
        private void Update()
        {
            if (soldierDataBlock == null)
            {
                return;
            }

            foreach (var soldier in randomSoldiers)
            {
                soldier.UpdateRandom(Time.deltaTime);
            }

            soldierDataBlock.UpdateRenderer();
        }