示例#1
0
        protected override void OnTick()
        {
            if (LastTickTime > lastUpdate)
            {
                foreach (MapObject obj in ObjectsInRegion)
                {
                    if (obj.IsSetForDeletion)
                    {
                        continue;
                    }

                    VBCharacter tmpChar = obj as VBCharacter;
                    if (tmpChar != null)
                    {
                        //notify player and hurt him
                        float range = (tmpChar.Position - Position).Normalize();

                        if (range < DamageRange)
                        {
                            tmpChar.DoDamage(this, tmpChar.Position, null, DamagePerUpdate, false);
                        }

                        GeigerCounter tmpCounter = tmpChar.ActiveHeldItem as GeigerCounter;
                        if (tmpCounter != null)
                        {
                            tmpCounter.UpdateSourceRange(range - DamageRange);
                        }
                    }
                }

                lastUpdate = LastTickTime + NextUpdate;
            }

            base.OnTick();
        }