Пример #1
0
        private void ExecuteEatCommand(long tick, EatCmd eatCmd)
        {
            Voxel eater = eatCmd.Eater.VoxelRef;

            if (eater == null || !eater.IsAcquired)
            {
                if (eatCmd.Voxel.VoxelRef != null)
                {
                    eatCmd.Voxel.VoxelRef.Kill();
                }
                return;
            }

            int   deltaHealth = eatCmd.EaterDeltaHealth;
            Voxel voxel       = eatCmd.Voxel.VoxelRef; //this change may break eat process. Possible that VoxelRef set to null previously

            if (voxel == null)
            {
                Debug.Assert(deltaHealth == 0);
                //if deltaHealth > 0 set texture directly
                return;
            }

            if (!voxel.IsAcquired)
            {
                Debug.Assert(deltaHealth == 0);
                //if deltaHealth > 0 set texture directly
                return;
            }

            if (deltaHealth == 0)
            {
                VoxelAbilities abilities = m_dataController.AllAbilities[eater.Owner][eater.Type];
                voxel.Smash(abilities.MovementDuration * GameConstants.MatchEngineTick / 3, eatCmd.VoxelHealth);
            }
            else if (deltaHealth == 1)
            {
                if (voxel.Type == (int)KnownVoxelTypes.Eater)
                {
                    SplitAndEat(tick, eater, deltaHealth, voxel);
                }
                else
                {
                    eater.BeginEat(voxel, tick);
                }
            }
            else if (deltaHealth > 1 && deltaHealth <= 8)
            {
                SplitAndEat(tick, eater, deltaHealth, voxel);
            }
            else
            {
                throw new NotImplementedException("deltaHealth " + deltaHealth);
            }
        }
Пример #2
0
        protected void EatAndExpand(long tick, float duration)
        {
            for (int i = 0; i < m_eatCommands.Count; ++i)
            {
                EatCmd eatCmd = m_eatCommands[i];
                ExecuteEatCommand(tick, eatCmd);
            }
            m_eatCommands.Clear();

            for (int i = 0; i < m_expandedVoxels.Count; ++i)
            {
                VoxelData expandedVoxel = m_expandedVoxels[i];
                if (expandedVoxel.VoxelRef != null)
                {
                    int height = expandedVoxel.Height;

                    expandedVoxel.VoxelRef.ChangeAltitude(expandedVoxel.VoxelRef.Altitude, expandedVoxel.Altitude, duration);
                    expandedVoxel.VoxelRef.Expand(height, duration);
                }
            }
            m_expandedVoxels.Clear();
        }
Пример #3
0
        protected override void OnVoxelRefResetOverride(Voxel voxel)
        {
            base.OnVoxelRefResetOverride(voxel);

            for (int i = 0; i < m_eatCommands.Count; ++i)
            {
                EatCmd cmd = m_eatCommands[i];
                if (cmd.Voxel != null && cmd.Voxel.VoxelRef != null)
                {
                    cmd.Voxel.VoxelRef.Kill();
                }
            }
            m_eatCommands.Clear(); //not cleared eat commands may lead to spawing of new objects
            CollapseEatExpandClear(m_currentTick);

            for (int i = m_explodeVoxels.Count - 1; i >= 0; --i)
            {
                ExplodeCmd explodeCmd = m_explodeVoxels[i];

                if (explodeCmd.VoxelData != m_controlledVoxel.VoxelData)
                {
                    if (explodeCmd.VoxelData.VoxelRef != null)
                    {
                        if (explodeCmd.VoxelData.IsAlive)
                        {
                            explodeCmd.VoxelData.VoxelRef.Health = explodeCmd.VoxelData.Health;
                        }
                        else
                        {
                            explodeCmd.VoxelData.VoxelRef.Kill();
                        }
                    }
                }
            }

            m_explodeVoxels.Clear();
        }