コード例 #1
0
        public bool ResolveCollision(GameObject gameObject, BotObject bot)
        {
            var currentEffect = new ActiveEffect
            {
                Bot    = bot,
                Effect = Effects.GasCloud
            };

            /* If the effect is not registered, add it to the list. */
            if (worldStateService.GetActiveEffectByType(bot.Id, Effects.GasCloud) != default)
            {
                if (bot.Size < engineConfig.MinimumPlayerSize)
                {
                    worldStateService.RemoveGameObjectById(bot.Id);
                }
                return(bot.Size >= engineConfig.MinimumPlayerSize);
            }

            worldStateService.AddActiveEffect(currentEffect);
            bot.Size -= engineConfig.GasClouds.AffectPerTick;
            if (bot.Size < engineConfig.MinimumPlayerSize)
            {
                worldStateService.RemoveGameObjectById(bot.Id);
            }
            return(bot.Size >= engineConfig.MinimumPlayerSize);
        }
コード例 #2
0
        public bool ResolveCollision(GameObject go, MovableGameObject mover)
        {
            var currentEffect = new ActiveEffect
            {
                Bot    = mover,
                Effect = Effects.GasCloud
            };


            if (mover is BotObject bot)
            {
                if (worldStateService.GetActiveEffectByType(bot.Id, Effects.GasCloud) != default)
                {
                    if (bot.Size < engineConfig.MinimumPlayerSize)
                    {
                        worldStateService.RemoveGameObjectById(bot.Id);
                    }
                    return(bot.Size >= engineConfig.MinimumPlayerSize);
                }

                worldStateService.AddActiveEffect(currentEffect);
                bot.Size -= engineConfig.GasClouds.AffectPerTick;
                if (bot.Size < engineConfig.MinimumPlayerSize)
                {
                    worldStateService.RemoveGameObjectById(bot.Id);
                }
                return(bot.Size >= engineConfig.MinimumPlayerSize);
            }
            else
            {
                var moverStartingSize = mover.Size;
                mover.Size -= go.Size;
                go.Size    -= moverStartingSize;
                if (go.Size <= 0)
                {
                    go.Size = 0;
                    worldStateService.RemoveGameObjectById(go.Id);
                }

                if (mover.Size <= 0)
                {
                    mover.Size = 0;
                    worldStateService.RemoveGameObjectById(mover.Id);
                }

                return(mover.Size > 0);
            }
        }
コード例 #3
0
        public bool ResolveCollision(GameObject gameObject, BotObject bot)
        {
            var currentEffect = new ActiveEffect
            {
                Bot    = bot,
                Effect = Effects.AsteroidField
            };

            /* If the effect is not registered, add it to the list. */
            if (worldStateService.GetActiveEffectByType(bot.Id, Effects.AsteroidField) == default)
            {
                worldStateService.AddActiveEffect(currentEffect);
                worldStateService.UpdateBotSpeed(bot);
            }

            return(true);
        }
コード例 #4
0
        public bool ResolveCollision(GameObject go, MovableGameObject mover)
        {
            var currentEffect = new ActiveEffect
            {
                Bot    = mover,
                Effect = Effects.AsteroidField
            };

            if (mover is BotObject bot)
            {
                /* If the effect is not registered, add it to the list. */
                if (worldStateService.GetActiveEffectByType(mover.Id, Effects.AsteroidField) == default)
                {
                    worldStateService.AddActiveEffect(currentEffect);
                    worldStateService.UpdateBotSpeed(mover);
                }
            }
            else
            {
                var moverStartingSize = mover.Size;
                mover.Size -= go.Size;
                go.Size    -= moverStartingSize;
                if (go.Size <= 0)
                {
                    go.Size = 0;
                    worldStateService.RemoveGameObjectById(go.Id);
                }

                if (mover.Size <= 0)
                {
                    mover.Size = 0;
                    worldStateService.RemoveGameObjectById(mover.Id);
                }

                return(mover.Size > 0);
            }



            return(true);
        }
コード例 #5
0
        public void ProcessAction(BotObject bot)
        {
            /* Bot does not have enough resources to consume for the afterburner. */
            if (bot.Size <= engineConfig.Afterburners.SizeConsumptionPerTick ||
                bot.Size <= engineConfig.MinimumPlayerSize)
            {
                return;
            }

            var currentEffect = new ActiveEffect
            {
                Bot    = bot,
                Effect = Effects.Afterburner
            };

            /* If the effect is not registered, add speed boost and add it to the list. */
            if (worldStateService.GetActiveEffectByType(bot.Id, Effects.Afterburner) == default)
            {
                worldStateService.AddActiveEffect(currentEffect);
                worldStateService.UpdateBotSpeed(bot);
            }
        }
コード例 #6
0
        public bool ResolveCollision(GameObject go, MovableGameObject mover)
        {
            // If the bot's ID has already been removed from the world, the bot is dead, return the alive state as false
            if (!worldStateService.GameObjectIsInWorldState(mover.Id))
            {
                return(false);
            }

            // If the colliding GO has already been removed from the world, but we reached here, the bot is alive but need not process the GO collision
            if (!worldStateService.GameObjectIsInWorldState(go.Id))
            {
                return(true);
            }

            if (mover.Size > engineConfig.WorldFood.MaxConsumptionSize)
            {
                return(true);
            }

            if (mover is BotObject bot)
            {
                bot.Size  += go.Size;
                bot.Score += engineConfig.ScoreRates[GameObjectType.Superfood];

                var superFoodEffect = worldStateService.GetActiveEffectByType(bot.Id, Effects.Superfood);
                if (superFoodEffect != null)
                {
                    superFoodEffect.EffectDuration += engineConfig.WorldFood.SuperfoodEffectDuration;
                }
                else
                {
                    var currentEffect = new ActiveEffect
                    {
                        Bot            = bot,
                        Effect         = Effects.Superfood,
                        EffectDuration = engineConfig.WorldFood.SuperfoodEffectDuration
                    };
                    worldStateService.AddActiveEffect(currentEffect);
                }
                worldStateService.UpdateBotSpeed(bot);
                go.Size = 0;
                worldStateService.RemoveGameObjectById(go.Id);
            }
            else
            {
                var moverStartingSize = mover.Size;
                mover.Size -= go.Size;
                go.Size    -= moverStartingSize;
                if (go.Size <= 0)
                {
                    go.Size = 0;
                    worldStateService.RemoveGameObjectById(go.Id);
                }

                if (mover.Size <= 0)
                {
                    mover.Size = 0;
                    worldStateService.RemoveGameObjectById(mover.Id);
                }
            }
            return(true);
        }