Esempio n. 1
0
        /// <summary>
        /// </summary>
        /// <param name="c">
        /// </param>
        private void CheckWallCollision(ICharacter c)
        {
            WallCollisionResult wcr = WallCollision.CheckCollision(c.Coordinates, c.Playfield.Identity.Instance);

            if (wcr != null)
            {
                int destPlayfield = wcr.SecondWall.DestinationPlayfield;
                if (destPlayfield > 0)
                {
                    if (Program.DebugZoning)
                    {
                        LogUtil.Debug(wcr.ToString());
                    }

                    PlayfieldDestination dest =
                        PlayfieldLoader.PFData[destPlayfield].Destinations[wcr.SecondWall.DestinationIndex];

                    if (Program.DebugZoning)
                    {
                        LogUtil.Debug(dest.ToString());
                    }

                    float newX      = (dest.EndX - dest.StartX) * wcr.Factor + dest.StartX;
                    float newZ      = (dest.EndZ - dest.StartZ) * wcr.Factor + dest.StartZ;
                    float dist      = WallCollision.Distance(dest.StartX, dest.StartZ, dest.EndX, dest.EndZ);
                    float headDistX = (dest.EndX - dest.StartX) / dist;
                    float headDistZ = (dest.EndZ - dest.StartZ) / dist;
                    newX -= headDistZ * 8;
                    newZ += headDistX * 8;

                    Coordinate destinationCoordinate = new Coordinate(newX, c.RawCoordinates.Y, newZ);

                    this.Teleport(
                        (Character)c,
                        destinationCoordinate,
                        c.RawHeading,
                        new Identity()
                    {
                        Type = IdentityType.Playfield, Instance = destPlayfield
                    });
                    return;
                }
            }
        }
Esempio n. 2
0
        private GameObject AddWall(string name, float width, List <Vector2> positions, Color color, WallCollisionResult wallCollisionResult)
        {
            GameObject   wall_object = new GameObject(name);
            LineRenderer renderer    = AddRenderer(width, wall_object, color);

            wall_object.transform.parent = transform;

            renderer.positionCount = positions.Count;
            for (int position = 0; position < renderer.positionCount; position++)
            {
                renderer.SetPosition(position, new Vector2(positions[position].x, positions[position].y));
            }

            AddCollider(wall_object, width, positions);

            Wall wall = wall_object.AddComponent <Wall>();

            wall.collisionResult = wallCollisionResult;
            walls.Add(wall);
            wall.number = walls.Count;

            return(wall_object);
        }
Esempio n. 3
0
 public Wall(WallCollisionResult collisionResult)
 {
     this.collisionResult = collisionResult;
 }