Exemplo n.º 1
0
    private void interactPorticoKey(TempPlayer player)
    {
        var living = GameObject.Find("Portico");

        living.GetComponent <PorticoGameplay>().Play();
        //player.AlowInteracting();
    }
Exemplo n.º 2
0
    private void interactTV(TempPlayer player)
    {
        var living = GameObject.Find("Living");

        AudioManager.Instance.PlayFX("Susto");
        living.GetComponent <RandomizeColor>().TurnOff();
        player.AlowInteracting();
    }
Exemplo n.º 3
0
    public void Loot(TempPlayer player)
    {
        if (remaindingCandy <= 0)
        {
            return;
        }

        if (TempPlayer.useKeyboardInput)
        {
            if (lootTick > 0.0f)
            {
                lootTick -= Time.deltaTime;
            }
            else
            {
                if (gameObject.GetComponent <AudioSource>())
                {
                    gameObject.GetComponent <AudioSource>().Play();
                }
                else
                {
                    print("No audio detected");
                }

                lootTick = lootDuration;

                --remaindingCandy;

                print("1 candy taken");
                print(remaindingCandy + " candies are left");

                player.addCandyPoints(1);

                GetComponentInChildren <ParticleSystem>().Play();
            }
        }
        else
        {
            if (gameObject.GetComponent <AudioSource>())
            {
                gameObject.GetComponent <AudioSource>().Play();
            }
            else
            {
                print("No audio detected");
            }

            lootTick = lootDuration;

            --remaindingCandy;

            print("1 candy taken");
            print(remaindingCandy + " candies are left");

            player.addCandyPoints(1);
        }
    }
Exemplo n.º 4
0
        public override void OnGameStart1()
        {
            base.OnGameStart1();
            TempPlayer?.OnGameStart1();
            var player = GetUnit(DBMgr.CurBaseGameData.PlayerID) as TUnit;

            if (player != null)
            {
                SetPlayer(player, true);
            }
        }
    public void GameStart(TempPlayer[] players) {
        lock (_lobbyActions)
            _lobbyActions.Enqueue(() => {
                GameObject lobbySettings = GameObject.Find("Lobby Settings");
                SessionData session = lobbySettings.GetComponent<SessionData>();
                session.Players = players;
                session.ServerCom = ComHandler;

                SceneManager.LoadScene("MultiplayerGame");
            });
    }
Exemplo n.º 6
0
    private void StartGame(string values) {
        string[] data = values.Split(new [] {")"}, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim('(')).ToArray();
        TempPlayer[] players = new TempPlayer[data.Length];

        for (int i = 0; i < data.Length; i++) {
            string[] playerData = data[i].Split(ValueDelimiter);
            players[i] = new TempPlayer() {
                Id = Int32.Parse(playerData[1]),
                Name = playerData[0]
            };
        }
        _lobby.GameStart(players);
    }
Exemplo n.º 7
0
    private void activeLevel(string levelName, TempPlayer player)
    {
        var currentLvl = levels.Select(x => x).FirstOrDefault(x => x.Active == true);

        currentLvl.Active = false;
        currentLvl.LevelObject.SetActive(false);

        var newLvl = levels.Select(x => x).FirstOrDefault(x => x.Key == levelName);

        newLvl.Active = true;
        newLvl.LevelObject.SetActive(true);

        player?.AlowInteracting();
    }
Exemplo n.º 8
0
 private void SetPlayers(string values) {
     string[] data = values.Split(ValueDelimiter);
     TempPlayer[] players = new TempPlayer[data.Length];
     for (int i = 0; i < players.Length; i++) {
         string info = data[i].Trim('(', ')');
         string[] splt = info.Split(':');
         players[i] = new TempPlayer() {
             Name = splt[0],
             Id = int.Parse(splt[1]),
             Ready = bool.Parse(splt[2]),
             IsHost = bool.Parse(splt[3])
         };
     }
     _lobby.SetPlayers(players);
 }
Exemplo n.º 9
0
    public override void Init()
    {
        playerObj    = FindObjectOfType <TempPlayer>();
        skillBoxObj  = GameObject.Find(skillBox);
        skillIconObj = GameObject.Find(skillIcon);
        isUnlocked   = false;

        if (playerObj != null)
        {
            originalDamage = playerObj.damage;
        }
        if (skillBoxObj != null)
        {
            skillBoxObj.SetActive(false);
        }
    }
Exemplo n.º 10
0
    private void interactDog(TempPlayer player)
    {
        if (interactuoConAlfombra)
        {
            var living = GameObject.Find("Portico");

            living.GetComponent <PorticoGameplay>().PararPerro();
            //player.AlowInteracting();
        }
        else
        {
            TextManager.Instance.LoadSequence(player, Constants.TextSequences.POE_DIALOGO);
            AudioManager.Instance.PlayFX("Dog");
        }
        player.AlowInteracting();
    }
Exemplo n.º 11
0
 // Start is called before the first frame update
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         DontDestroyOnLoad(this);
         _currentPlayer            = null;
         _showing                  = false;
         _haveSequenceToPlay       = false;
         textBoxTransform.position =
             new Vector3(textBoxTransform.position.x, -heightOffset, textBoxTransform.position.y);
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
Exemplo n.º 12
0
        public static void ClientConnected(Int32 id)
        {
            if (Data.Players.ContainsKey(id))
            {
                return;
            }

            // Create ourselves a brand new Player class and assign it to the appropriate ID.
            var temp  = new Player();
            var tempp = new TempPlayer();

            Data.Players.Add(id, temp);
            Data.TempPlayers.Add(id, tempp);

            // Send the ID to our player.
            Send.PlayerID(id);

            Logger.Write(String.Format("ID: {0} has connected.", id));
        }
Exemplo n.º 13
0
    public void LoadSequence(TempPlayer currentPlayer, string sequenceName)
    {
        var filePath = Application.streamingAssetsPath + "\\" + sequenceName;

        if (!File.Exists(filePath))
        {
            Debug.LogError($"Algo malio sal y no encontre el archivo en el path {filePath}");
            return;
        }

        _currentPlayer      = currentPlayer;
        _haveSequenceToPlay = true;
        var contents = File.ReadAllText(filePath);

        Debug.Log(contents);
        currentSequence = Sequence.FromJson(contents);
        _blockCount     = currentSequence?.blocks?.Length ?? 0;
        LoadBlock(0);
    }
 public void SetPlayers(TempPlayer[] players) {
     //TODO: Set host & ready status
     lock (_lobbyActions)
         _lobbyActions.Enqueue(() => {
             SessionData session = GameObject.Find("Lobby Settings").GetComponent<SessionData>();
             TempPlayer host = players.FirstOrDefault(x => x.IsHost);
             if(host != null)
                 HostField.text = host.Name;
             TempPlayer[] nonHosts = players.Where(x => !x.IsHost).ToArray();
             for (int i = 0; i < PlayerFields.Length; i++) {
                 if (i < nonHosts.Length) {
                     PlayerFields[i].text = nonHosts[i].Name;
                     PlayerReadyObjects[i].GetComponent<Image>().color = Color.white;
                     PlayerReadyObjects[i].GetComponent<Image>().sprite = nonHosts[i].Ready
                         ? ReadyImage
                         : NotReadyImage;
                 }
                 else {
                     PlayerFields[i].text = "";
                     PlayerReadyObjects[i].GetComponent<Image>().sprite = NotReadyImage;
                     PlayerReadyObjects[i].GetComponent<Image>().color = Color.clear;
                 }
             }
             LobbyButtonEvents events = ReadyStartButton.GetComponent<LobbyButtonEvents>();
             if (host.Id == session.OwnId) {
                 events.ButtonType = "Start";
                 if (players.Any(x => !x.Ready && !x.IsHost))
                     events.Enabled = false;
                 else
                     events.Enabled = true;
             }
             else {
                 events.ButtonType = "Ready";
                 events.Enabled = true;
             }
         });
 }
Exemplo n.º 15
0
    public void SetNameHandshake(string response) {
        LoginStatus login = GetLoginStatus();
        SessionData session = GetSession();

        IPEndPoint lobbyIp = GetLobbyIp(response);
        if (lobbyIp == null) {
            EndSession();
            return;
        }
        // TODO: Method v
        Socket tcp = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        tcp.Connect(lobbyIp);
        TcpClient tcpClient = new TcpClient(tcp);


        string auth = GetResponse(tcpClient.Socket, string.Format("[Notify:SetName:{0}]", login.Name));
        if (auth == null) {
            EndSession();
            return;
        }

        string[] messages =
            auth.Split(new [] { "]" }, StringSplitOptions.RemoveEmptyEntries)
                .Select(x => x.TrimStart('['))
                .ToArray();

        SplitData first = messages[0].GetFirst();
        if (first.CommandType == "Error") {
            ShowError(first.Values.Split(':').Last());
            return;
        }

        string[] authData = messages[0].GetFirst().Values.GetFirst().Values.Split(new [] {"|",}, StringSplitOptions.RemoveEmptyEntries);
        session.Guid = authData[0];
        session.OwnId = Int32.Parse(authData[1]);
        session.OwnName = authData[2];
        session.LobbyId = authData[3];
        session.LobbyConnection = tcpClient;

        string[] playerData = messages[1].GetFirst().Values.GetFirst().Values.Split(new[] { "|", }, StringSplitOptions.RemoveEmptyEntries).ToArray();
        TempPlayer[] players = new TempPlayer[playerData.Length];
        for (int i = 0; i < players.Length; i++) {
            string info = playerData[i].Trim('(', ')');
            string[] splt = info.Split(':');
            players[i] = new TempPlayer() {
                Name = splt[0],
                Id = int.Parse(splt[1]),
                Ready = bool.Parse(splt[2]),
                IsHost = bool.Parse(splt[3])
            };
        }

        session.Players = players;
        SceneManager.LoadScene("Lobby");
    }
Exemplo n.º 16
0
 public override void OnWrite <TDBData>(TDBData data)
 {
     base.OnWrite(data);
     TempPlayer?.OnWrite(data);
 }
Exemplo n.º 17
0
 public override void OnReadEnd <TDBData>(TDBData data)
 {
     base.OnReadEnd(data);
     TempPlayer?.OnReadEnd(data);
 }
Exemplo n.º 18
0
 public override void OnGameStartOver()
 {
     base.OnGameStartOver();
     TempPlayer?.OnGameStartOver();
 }
Exemplo n.º 19
0
    // Use this for initialization
    void Start()
    {
        tPlayer = GameObject.FindGameObjectWithTag("Player").GetComponent <TempPlayer>();

        gameObject.GetComponent <LevelTransition>().isActive = false;
    }
Exemplo n.º 20
0
    public void Interact(string key, TempPlayer player)
    {
        switch (key)
        {
        case "Atico":
            activeLevel("Atico", player);
            break;

        case "Mother_bedroom":
            activeLevel("Mother_bedroom", player);
            break;

        case "Livingroom":
            activeLevel("Livingroom", player);
            break;

        case "Alma_bedroom":
            TextManager.Instance.LoadSequence(player, Constants.TextSequences.ALMA_ROOM_DIALOGO);
            break;

        case "Hall":
            activeLevel("Hall", player);
            break;

        case "Inventory":
            Inventory.Instance.ShowHidde();
            break;

        case "Sister_bedroom":
            activeLevel("Sister_bedroom", player);
            break;

        case "Sister_bedroom2":
            activeLevel("Sister_bedroom2", player);
            break;

        case "TV":
            interactTV(player);
            break;

        case "Atic_Box":
            TextManager.Instance.LoadSequence(player, Constants.TextSequences.ATIC_DIALOGO);
            maquinaBien = true;
            break;

        case "Picture":
            TextManager.Instance.LoadSequence(player, Constants.TextSequences.CUADRO_DIALOGO);
            break;

        case "Drawer":
            if (haveDrawerKey)
            {
                AudioManager.Instance.PlayFX("Drawer");
                //TODO: Puzzle
                PuzzleManager.Instance.LoadPuzzle("diario", () => ChangeAct(), levels.Select(x => x).FirstOrDefault(x => x.Active == true).LevelObject.GetComponentInChildren <Camera>());
//                    ChangeAct();
            }
            else
            {
                TextManager.Instance.LoadSequence(player, Constants.TextSequences.DRAWER_DIALOGO);
            }
            break;

        case "Key":
            interactPorticoKey(player);
            break;

        case "Dog":
            interactDog(player);
            break;

        case "Alfombra":
            //Texto de acá había una llave
            interactuoConAlfombra = true;
            TextManager.Instance.LoadSequence(player, Constants.TextSequences.ALFOMBRA_DIALOGO);
            break;

        case "Diario1":
            TextManager.Instance.LoadSequence(player, Constants.TextSequences.DIARIO1_DIALOGO);
            break;

        case "Diario2":
            TextManager.Instance.LoadSequence(player, Constants.TextSequences.LECTURA_DIARIO);
            break;

        case "Cartas":
            //Puzzle
            break;

        case "typewriter":
            if (maquinaBien)
            {
                player.Possess();
                TextManager.Instance.LoadSequence(player, Constants.TextSequences.CARTA_FINAL);
            }
            else
            {
                TextManager.Instance.LoadSequence(player, Constants.TextSequences.MAQUINA_ROTA_DIALOG);
            }
            break;

        case "BedTable":
            haveDrawerKey = true;
            TextManager.Instance.LoadSequence(player, Constants.TextSequences.LLAVE_MESALUZ);
            break;
        }
    }
Exemplo n.º 21
0
 public override void OnLoginInit3(object data)
 {
     base.OnLoginInit3(data);
     TempPlayer?.OnLoginInit3(data);
 }
Exemplo n.º 22
0
 void Start()
 {
     movementScript = GetComponentInParent <PlayerMovementGyro>();
     tp             = GetComponentInParent <TempPlayer>();
 }