示例#1
0
        public LaserPoint GetNextCoordinates(LaserDirection laserDirection)
        {
            var nextCoordinates = new GridCoordinates(Coordinates.X, Coordinates.Y);

            switch (laserDirection)
            {
            case LaserDirection.Up:
                nextCoordinates.Y += 1;
                break;

            case LaserDirection.Down:
                nextCoordinates.Y -= 1;
                break;

            case LaserDirection.Left:
                nextCoordinates.X -= 1;
                break;

            case LaserDirection.Right:
                nextCoordinates.X += 1;
                break;

            default:
                break;
            }

            return(new LaserPoint {
                Coordinates = nextCoordinates, Direction = laserDirection
            });
        }
示例#2
0
    public void Initialize(LaserBeamAssault lba, float laserSpeed, LaserDirection dir, LaserPosition pos, float lifespan, float topRotation, float bottomRotation)
    {
        destructionTimer           = lifespan;
        assault                    = lba;
        speed                      = laserSpeed;
        laserDirection             = dir;
        laserPosition              = pos;
        topLaserInitialRotation    = topRotation;
        bottomLaserInitialRotation = bottomRotation;

        if (dir == LaserDirection.RIGHT)
        {
            if (laserPosition == LaserPosition.TOP)
            {
                this.transform.rotation = Quaternion.Euler(0, 0, topLaserInitialRotation);
            }
            else
            {
                this.transform.rotation = Quaternion.Euler(0, 0, bottomLaserInitialRotation);
            }
        }
        else
        {
            if (laserPosition == LaserPosition.TOP)
            {
                this.transform.rotation = Quaternion.Euler(0, 0, -topLaserInitialRotation);
            }
            else
            {
                this.transform.rotation = Quaternion.Euler(0, 0, -bottomLaserInitialRotation);
            }
        }
    }
示例#3
0
    public void RotateTower(TowerController tower, LaserDirection direction)
    {
        PlayGridLoc loc = playGrid[tower.gridRow, tower.gridCol];

        if (loc.direction == direction)
        {
            return;                                     // Nothing to do. Skip recalculation.
        }
        loc.direction = direction;
        RecalculateGrid();
    }
        private LaserDirection SetLaserDirection(LaserDirection currentDirection)
        {
            if (_mirror.MirrorType == MirrorType.OneWayReflectOnLeft)
            {
                return(Constants.RightAngleReflectLeft.ContainsKey(currentDirection) ?
                       Constants.RightAngleReflectLeft[currentDirection] : currentDirection);
            }
            if (_mirror.MirrorType == MirrorType.OneWayReflectOnRight)
            {
                return(Constants.RightAngleReflectRight.ContainsKey(currentDirection) ?
                       Constants.RightAngleReflectLeft[currentDirection] : currentDirection);
            }

            return(Constants.RightAngleTwoWay[currentDirection]);
        }
示例#5
0
        public Laser(World world, LaserDirection direction) : base(world, EntityType.LASER)
        {
            this.direction  = direction;
            sourceRectangle = new Rectangle(0, (int)direction * 32, 32, 32);
            isHorizontal    = (direction == LaserDirection.HORIZONTAL);

            if (isHorizontal)
            {
                length   = world.Map.Width;
                boundBox = new Rectangle(0, 0, length * 32, 32);
                Position = new Vector2(0, random.Next(0, world.Map.Height) * 32);
                xOffset  = 0;
                yOffset  = 10;
            }
            else
            {
                length   = world.Map.Height;
                boundBox = new Rectangle(0, 0, 32, length * 32);
                Position = new Vector2(random.Next(0, world.Map.Width) * 32, 0);
                xOffset  = 10;
                yOffset  = 0;
            }
        }
        public LaserPoint GetNextLaserPosition(LaserDirection currentDirection)
        {
            var newLaserDirection = SetLaserDirection(currentDirection);

            return(GetNextCoordinates(newLaserDirection));
        }
示例#7
0
 public PlayGridLoc(TowerController t, LaserDirection d, PlayerTeam te)
 {
     tower     = t;
     direction = d;
     team      = te;
 }
示例#8
0
 public LaserPoint GetNextLaserPosition(LaserDirection currentDirection)
 {
     return(GetNextCoordinates(currentDirection));
 }
示例#9
0
文件: Client.cs 项目: aeren108/kaymak
        public void Update()
        {
            NetIncomingMessage inMsg;

            while ((inMsg = client.ReadMessage()) != null)
            {
                switch (inMsg.MessageType)
                {
                case NetIncomingMessageType.Data:
                    string dataType = inMsg.ReadString();
                    if (dataType.Equals("newplayer"))
                    {
                        Player p = new Player(world);

                        string username = inMsg.ReadString();
                        int    id       = inMsg.ReadInt32();

                        if (players[id] != null)
                        {
                            Console.WriteLine("Aboooov   {0}     {1}", id, username);
                            break;
                        }

                        float x = inMsg.ReadFloat();
                        float y = inMsg.ReadFloat();

                        p.Position  = new Vector2(x, y);
                        p.Username  = username;
                        p.IsPrimary = false;
                        p.LoadContent();

                        world.entities.Add(p);
                        players[id] = p;
                        Console.WriteLine(players[id] + "  Abidin gubidin");
                    }
                    else if (dataType.Equals("move"))
                    {
                        string username = inMsg.ReadString();
                        int    id       = inMsg.ReadInt32();

                        if (players[id] != null)
                        {
                            Player p = players[id];

                            float x       = inMsg.ReadFloat();
                            float y       = inMsg.ReadFloat();
                            int   animNum = inMsg.ReadInt32();
                            p.CurAnim = p.GetAnimByAnimNum(animNum);
                            Vector2 newPos = new Vector2(x, y);

                            p.Position = newPos;
                        }
                        else
                        {
                            Console.WriteLine("Yok artık daha neler  :::::: {0} ,,,,,, {1}", username, id);
                        }
                    }
                    else if (dataType.Equals("fireball"))
                    {
                        int dir = inMsg.ReadInt32();
                        FireballDirection fbdir = dir == 0 ? FireballDirection.HORIZONTAL : FireballDirection.VERTICAL;
                        Fireball          fb    = new Fireball(world, fbdir);
                        fb.Position.X = inMsg.ReadInt32();
                        fb.Position.Y = inMsg.ReadInt32();

                        fb.LoadContent();
                        world.entities.Add(fb);
                    }
                    else if (dataType.Equals("laser"))
                    {
                        int            dir  = inMsg.ReadInt32();
                        LaserDirection ldir = dir == 0 ? LaserDirection.HORIZONTAL : LaserDirection.VERTICAL;
                        Laser          l    = new Laser(world, ldir);
                        l.Position.X = inMsg.ReadInt32();
                        l.Position.Y = inMsg.ReadInt32();

                        l.LoadContent();
                        world.entities.Add(l);
                    }
                    break;
                }
            }
            client.Recycle(inMsg);
        }