Пример #1
0
        public override void OnThink()
        {
            if (Combatant == null)
            {
                return;
            }
            Direction d = this.GetDirectionTo(Combatant);

            if (Direction != d)
            {
                Direction = d;
            }
            if (Cannon.Direction != Direction)
            {
                switch (Direction)
                {
                case Direction.Up:
                case Direction.North:
                {
                    Cannon.Delete();
                    Cannon = new CannonNorth(this);
                    Cannon.MoveToWorld(new Point3D(X, Y - 3, Z), Map);
                    Cannon.Direction = Direction;
                    break;
                }

                case Direction.Down:
                case Direction.South:
                {
                    Cannon.Delete();
                    Cannon = new CannonSouth(this);
                    Cannon.MoveToWorld(new Point3D(X, Y + 1, Z), Map);
                    Cannon.Direction = Direction;
                    break;
                }

                case Direction.Right:
                case Direction.East:
                {
                    Cannon.Delete();
                    Cannon = new CannonEast(this);
                    Cannon.MoveToWorld(new Point3D(X + 1, Y, Z), Map);
                    Cannon.Direction = Direction;
                    break;
                }

                case Direction.Left:
                case Direction.West:
                {
                    Cannon.Delete();
                    Cannon = new CannonWest(this);
                    Cannon.MoveToWorld(new Point3D(X - 3, Y, Z), Map);
                    Cannon.Direction = Direction;
                    break;
                }
                }
            }
            base.OnThink();
        }
 protected override void OnLocationChange(Point3D oldLoc)
 {
     if (Cannon == null)
     {
         Cannon    = new CannonWest(this);
         Direction = Direction.West;
         Cannon.MoveToWorld(new Point3D(X - 3, Y, Z), Map);
     }
     else
     {
         Direction = Direction.West;
         Cannon.MoveToWorld(new Point3D(X - 3, Y, Z), Map);
     }
     base.OnLocationChange(oldLoc);
 }
        public void GetDirection()
        {
            switch (Direction)
            {
            case Direction.Up:
            case Direction.North:
            {
                Cannon.Delete();
                Cannon = new CannonNorth(this);
                Cannon.MoveToWorld(new Point3D(X, Y - 3, Z), Map);
                Cannon.Direction = Direction;
                break;
            }

            case Direction.Down:
            case Direction.South:
            {
                Cannon.Delete();
                Cannon = new CannonSouth(this);
                Cannon.MoveToWorld(new Point3D(X, Y + 1, Z), Map);
                Cannon.Direction = Direction;
                break;
            }

            case Direction.Right:
            case Direction.East:
            {
                Cannon.Delete();
                Cannon = new CannonEast(this);
                Cannon.MoveToWorld(new Point3D(X + 1, Y, Z), Map);
                Cannon.Direction = Direction;
                break;
            }

            case Direction.Left:
            case Direction.West:
            {
                Cannon.Delete();
                Cannon = new CannonWest(this);
                Cannon.MoveToWorld(new Point3D(X - 3, Y, Z), Map);
                Cannon.Direction = Direction;
                break;
            }
            }
        }