Ejemplo n.º 1
0
    public void FindOrientation()
    {
        orientation = Player.Orientation.None;

        foreach (var inputPart in InputInfo.parts)
        {
            // actuellement ça fonctionne pas trop aprce que "devant à droite" c'est plusieurs parties par exemple
            string[] strs = new string[8]
            {
                "devant",
                "devant à droite",
                "droite",
                "derrière à droite",
                "derrière",
                "derrière à gauche",
                "gauche",
                "devant à gauche"
            };

            Player.Orientation tmpOrientation = (Player.Orientation) 0;

            foreach (var str in strs)
            {
                if (inputPart.Contains(str))
                {
                    orientation = tmpOrientation;
                    //Debug.Log("found orientation : " + orientation.ToString());
                    return;
                }

                ++tmpOrientation;
            }
        }
    }
Ejemplo n.º 2
0
    public static string GetRelativeItemPositionPhrase(Item item)
    {
        string itemPosition = "";

        Player.Orientation fac = Player.Orientation.None;

        switch (item.GetProperty("direction").GetContent())
        {
        case "to north":
            fac = Player.Instance.GetFacing(Direction.North);
            break;

        case "to south":
            fac = Player.Instance.GetFacing(Direction.South);
            break;

        case "to east":
            fac = Player.Instance.GetFacing(Direction.East);
            break;

        case "to west":
            fac = Player.Instance.GetFacing(Direction.West);
            break;

        default:
            break;
        }

        switch (fac)
        {
        case Player.Orientation.Front:
            itemPosition = "devant vous";
            break;

        case Player.Orientation.Right:
            itemPosition = "à droite";
            break;

        case Player.Orientation.Back:
            itemPosition = "derrière vous";
            break;

        case Player.Orientation.Left:
            itemPosition = "à gauche";
            break;

        default:
            break;
        }

        return(itemPosition);
    }
Ejemplo n.º 3
0
    public static Direction GetRelativeDirection(Direction direction, Player.Orientation facing)
    {
        int a = (int)direction + (int)facing;

        if (a >= 8)
        {
            a -= 8;
        }

        //		Debug.Log ( "player is turned " + direction + ", so the returned dir is " + (Direction)a );

        return((Direction)a);
    }
Ejemplo n.º 4
0
    public static string GetOrientationText(Player.Orientation orientation)
    {
        string[] directionPhrases = new string[8] {
            "devant vous",
            "quelques pas devant vous, vers la droite",
            Random.value < 0.5f ? "à votre droite" : "sur votre droite",
            "derrière vous, à droite",
            "derrière vous",
            "derrière vous, à gauche",
            Random.value < 0.5f ? "à votre gauche" : "sur votre gauche",
            "quelques pas devant vous, à votre gauche"
        };

        return(directionPhrases[(int)orientation]);
    }
Ejemplo n.º 5
0
    public void AddPlayer(uint id, string name, uint level, Vector2 position, Player.Orientation direction)
    {
        GameObject instance  = GameObject.Instantiate(Resources.Load("GameObjects/Player/Prefab/Player")) as GameObject;
        Player     newPlayer = instance.GetComponent <Player>();

        if (newPlayer != null)
        {
            if (!Teams.ContainsKey(name))
            {
                GameManager.Instance.Teams[name] = new Team(GameManager.Instance.Teams.Count, name);
            }
            newPlayer.Init(id, Teams[name], level, position, direction);
            Players[id] = newPlayer;
        }
        GameUIManager.AddPlayer(name);
    }
Ejemplo n.º 6
0
    public Vector3 ConvertOrientation(Player.Orientation orientation)
    {
        switch (orientation)
        {
        case Player.Orientation.NORTH:
            return(new Vector3(0, 0, 0));

        case Player.Orientation.EAST:
            return(new Vector3(0, 90, 0));

        case Player.Orientation.SOUTH:
            return(new Vector3(0, 180, 0));

        case Player.Orientation.WEST:
            return(new Vector3(0, 270, 0));
        }
        ;
        return(Vector3.zero);
    }
Ejemplo n.º 7
0
 public void UpdatePlayerPos(string[] res)
 {
     if (res.Length == 5 && res[0] == "ppo")
     {
         Player             p           = spawnManager.FindPlayerById(int.Parse(res[1]));
         Player.Orientation orientation = (Player.Orientation) int.Parse(res[4]);
         int x = int.Parse(res[2]);
         int y = int.Parse(res[3]);
         if (p != null)
         {
             if (p.IsPositionDifferent(x, y))
             {
                 StartCoroutine(p.Move(x, y));
             }
             else if (p.IsOrientationDifferent(orientation))
             {
                 StartCoroutine(p.Turn(orientation));
             }
             p.nexGgridPos.x   = x;
             p.nexGgridPos.y   = y;
             p.nextOrientation = orientation;
         }
     }
 }
Ejemplo n.º 8
0
    public void newRound(bool startNow)
    {
        //reset positions
        lastAlivePlayer = null;
        gameEnding      = false;
        if (numPlayers == 2)
        {
            for (int i = 0; i < numPlayers; i++)
            {
                players[i].transform.position = new Vector3(
                    playerBaseLine * Mathf.Pow(-1, i),
                    -5.0f + Player.playerHeight,
                    0.0f);
                if (i == 0)
                {
                    players[i].orientation = players[i].newOrientation = Player.Orientation.West;
                }
                else
                {
                    players[i].orientation = players[i].newOrientation = Player.Orientation.East;
                }
                players[i].SetOrientation();
            }
        }
        else
        {
            int player         = 0;
            int playersPerSide = Mathf.Min(numPlayers / 4, 1);
            for (int side = 0; side < 4; side++)
            {
                float sideX = 0, sideY = 0;
                Player.Orientation orientation = Player.Orientation.North;
                switch (side)
                {
                case 0:
                    sideX       = playerBaseLine;
                    orientation = Player.Orientation.West;
                    break;

                case 1:
                    sideX       = -playerBaseLine;
                    orientation = Player.Orientation.East;
                    break;

                case 2:
                    sideY       = playerBaseLine;
                    orientation = Player.Orientation.South;
                    break;

                case 3:
                    sideY       = -playerBaseLine;
                    orientation = Player.Orientation.North;
                    break;

                default:
                    Debug.LogError("Error while positioning players");
                    break;
                }
                for (int i = 0; i < playersPerSide; i++)
                {
                    if (player >= numPlayers)
                    {
                        break;
                    }
                    float offset = (1.0f / (playersPerSide + 1) * (i + 1)) * 10.0f - 5.0f;
                    if (sideY == 0)
                    {
                        sideY = offset;
                    }
                    else
                    {
                        sideX = offset;
                    }
                    players[player].transform.position = new Vector3(sideX,
                                                                     -5.0f + Player.playerHeight,
                                                                     sideY);
                    players[player].orientation = players[player].newOrientation = orientation;

                    player++;
                }
            }
        }
        foreach (Player p in players)
        {
            p.newRound();
        }
        if (startNow)
        {
            StartCoroutine(Countdown("GO"));
        }
    }
Ejemplo n.º 9
0
        public void Initialize(Texture2D texture, Vector2 position,
                                int frameWidth, int frameHeight, int frameCount,
                                int frametime, Color color, float scale, bool looping)
        {
            // Keep a local copy of the values passed in
            this.color = color;
            this.FrameWidth = frameWidth;
            this.FrameHeight = frameHeight;
            this.frameCount = frameCount;
            this.frameTime = frametime;
            this.scale = scale;

            facesDirection = Player.Orientation.facesLeft;

            Looping = looping;
            Position = position;
            spriteStrip = texture;

            // Set the time to zero
            elapsedTime = 0;
            currentFrame = 0;

            // Set the Animation to active by default
            Active = true;
        }
Ejemplo n.º 10
0
 public void Move(Player.Orientation orientation)
 {
     Move(GetDirection(orientation));
 }