Ejemplo n.º 1
0
    public void SwitchMove()
    {
        fail = true;
        // Debug to check movement and direction
        Debug.Log("I AM MOVING " + direction);

        int x = 0;
        int y = 0;

        currentPosition = currentRoom.coordinate;

        Int32.TryParse(currentPosition[0].ToString(), out x);
        Int32.TryParse(currentPosition[1].ToString(), out y);

        switch (direction)
        {
        case "up":
            y += 1;
            break;

        case "down":
            y -= 1;
            break;

        case "right":
            x += 1;
            break;

        case "left":
            x -= 1;
            break;

        default:
            break;
        }

        string tryCoordinate = x.ToString() + y.ToString();

        if (RoomCoords.coordinates.ContainsKey(tryCoordinate))
        {
            currentRoom = RoomCoords.coordinates[tryCoordinate];
            direction   = "center";
            currentRoom.Enter();
            currentRoom.Standing();
        }
        else
        {
            // Dead end debug
            Debug.Log("TRY AGAIN SOMEWHERE ELSE");
            fail        = true;
            movingTimer = 0f;
        }
    }
Ejemplo n.º 2
0
    void CheckSpace()
    {
        int x = 0;
        int y = 0;

        currentPosition = currentRoom.coordinate;

        Int32.TryParse(currentPosition[0].ToString(), out x);
        Int32.TryParse(currentPosition[1].ToString(), out y);

        switch (direction)
        {
        case "up":
            y += 1;
            break;

        case "down":
            y -= 1;
            break;

        case "right":
            x += 1;
            break;

        case "left":
            x -= 1;
            break;

        default:
            break;
        }

        string tryCoordinate = x.ToString() + y.ToString();

        if (!RoomCoords.GetComponent <GlobalTimer>().outside)
        {
            if (!RoomCoords.coordinates.ContainsKey(tryCoordinate))
            {
                Debug.Log("THIS IS DEAD END");
                GetComponent <_CHECK_DEADEND>().SetDeadend();
            }
            else
            {
                if (RoomCoords.coordinates[tryCoordinate] == RoomCoords.exit)
                {
                    AkSoundEngine.SetRTPCValue("Outside_Listen", 3);
                    GetComponent <_OUTSIDE>().TheBirds();
                    RoomCoords.coordinates[tryCoordinate].Listen();
                }
                else if (RoomCoords.coordinates[tryCoordinate] != currentRoom)
                {
                    RoomCoords.coordinates[tryCoordinate].Listen();
                }
                else if (RoomCoords.coordinates[tryCoordinate] == currentRoom)
                {
                    currentRoom.Standing();
                    GetComponent <_WALK>().Walk();
                }

                if (world.threatened.Contains(RoomCoords.coordinates[tryCoordinate]))
                {
                    if (world.threatened[0] == RoomCoords.coordinates[tryCoordinate])
                    {
                        //Debug.Log("X:" + x);
                        //Debug.Log("Y:" + y);
                        //Debug.Log("MONSTER NEXT DOOR");
                        AkSoundEngine.SetRTPCValue("Monster_Coming", 3);
                    }
                    else
                    {
                        if (monster.GetComponent <MonsterMovement>().toMove == 0)
                        {
                            AkSoundEngine.SetRTPCValue("Monster_Coming", 1);
                        }
                        else
                        {
                            AkSoundEngine.SetRTPCValue("Monster_Coming", 2);
                        }
                    }
                    GetComponent <MONSTER_CLOSER>().Step();
                }
                else
                {
                    //Debug.Log("BYE");
                    GetComponent <MONSTER_TOO_FAR>().Bye();
                }
            }
        }
        else if (!outside)
        {
            AkSoundEngine.SetRTPCValue("Outside_Listen", 3);
            GetComponent <_OUTSIDE>().TheBirds();
            outside = true;
        }

        // if (RoomCoords.exit.coordinate == tryCoordinate && !outside)
        // {
        // GetComponent<_OUTSIDE>().TheBirds();
        // outside = true;
        // }
        // else
        // {
        // int exitX = 0;
        // int exitY = 0;

        // Int32.TryParse(RoomCoords.exit.coordinate[0].ToString(), out exitX);
        // Int32.TryParse(RoomCoords.exit.coordinate[1].ToString(), out exitY);

        // float distanceToExit = (float)Math.Sqrt((x - exitX) ^ 2 + (y - exitY) ^ 2);

        // if(Math.Floor(distanceToExit) > 3)
        // GetComponent<_WALK>().Walk();
        // //GetComponent<_IS_NEAR_EXIT>().TheLight();

        // AkSoundEngine.SetRTPCValue("Outside_Listen", 0);
        // }

        playedSound = true;
        timer       = 0;
    }