Example #1
0
    public void RemovePlayer(PlayerStuff player)
    {
        if (players.Count == 2)
        {
            // winner is ----  player.nextPlayer
            print("winner is " + player.nextPlayer);

            GameObject.DontDestroyOnLoad(gameInfo);
            gameInfo.GetComponent <information>().WinnerName = player.nextPlayer.name;
            UnityEngine.SceneManagement.SceneManager.LoadScene(2);
        }
        else
        {
            foreach (var item in players)
            {
                if (item.nextPlayer == player)
                {
                    item.nextPlayer = player.nextPlayer;
                }
            }

            players.Remove(player);

            player.tablePlayer.SetActive(false);
            player.gameObject.SetActive(false);
        }
    }
Example #2
0
    public void AddCard(Card card)
    {
        PlayerStuff player = GetComponent <PlayerStuff>();

        property.Add(card);
        card.Color = player.color;
        card.owner = player;

        var p = GameObject.Instantiate(particles);

        p.transform.SetParent(card.transform);
        p.transform.position = card.transform.position;
        print("Количество карт данной монополии - " + property.Where(x => x.index == card.index).ToArray().Length + ". Необходимо - " + cards.fullMonopolyQuants[card.index]);

        if (property.Where(x => x.index == card.index).ToArray().Length == cards.fullMonopolyQuants[card.index])
        {
            property.Where(x => x.index == card.index).Select(x => x.isMonopoly = true).ToList();
            print("Монополия создана у игрока " + player);
        }

        if (!propUpgrades.ContainsKey(card.index))
        {
            propUpgrades.Add(card.index, new List <Card>());
        }
        propUpgrades[card.index].Add(card);
    }
 // Use this for initialization
 void Start()
 {
     agent        = main.GetComponent <NavMeshAgent>();
     triggered    = false;
     anim         = GetComponent <Animator>();
     playerScript = player.GetComponent <PlayerStuff>();
 }
Example #4
0
 public virtual void OnGeneralEvent(PlayerStuff stuff)
 {
     if (GeneralEvent != null)
     {
         GeneralEvent(this, stuff);
     }
 }
    // when a player is added make sure that lists are populated properly, and the player UI element is showen
    public void OnPlayerJoined(PlayerInput playerInput)
    {
        // add player to list
        Players.Add(playerInput);

        PlayerStuff thisPlayer = new PlayerStuff();

        thisPlayer.Pannal    = UnCheckedOutPannals[0];
        thisPlayer.Ready     = false;
        thisPlayer.myDevice  = playerInput.devices.First();
        thisPlayer.PlayerNum = Players.Count;
        for (int i = 0; i < AmountOfChar; i++)
        {
            if (!CheckedoutChars.ContainsKey(i))
            {
                selectImage(thisPlayer.Pannal.transform.GetChild(2).GetChild(i).GetComponentInChildren <Image>());
                thisPlayer.SelectedChar = i;
                break;
            }
        }


        Debug.Log("player # " + thisPlayer.PlayerNum + "paird with device" + thisPlayer.myDevice.name);

        CheckedOutPannals.Add(playerInput, thisPlayer);
        CheckedOutPannals[playerInput].Pannal.SetActive(true);

        UnCheckedOutPannals.RemoveAt(0);

        playerInput.GetComponent <AddUiPlayer>().controller = gameObject.GetComponent <playerAddController>();
    }
Example #6
0
    public void Pay()
    {
        PlayerStuff player = GetComponent <Turn>().player;
        Card        card   = player.targetCard;


        if (player.gameObject.GetComponent <Money>().Transaction(card.cost))
        {
            if (card.owner != null)
            {
                card.owner.GetComponent <Money>().Transaction(-card.cost);

                print("Владельцу карты начислены деньги");
            }

            print("Опреция завершена");
            if (player.inJail)
            {
                player.GoOutOfJail();
            }
            player.EndTurn();
        }
        else
        {
            print("Недостаточно стредств");
        }
    }
Example #7
0
 public void EnableTradeMenu(PlayerStuff player)
 {
     tradeMenu.gameObject.SetActive(true);
     tradeMenu.GetComponentsInChildren <Text>()[0].text = turn.player.name;
     tradeMenu.GetComponentsInChildren <Text>()[1].text = player.name;
     tradeMenu.GetComponent <Trade>().secondTrader      = player;
 }
    public void UnReadyPlayer(PlayerInput player)
    {
        PlayerStuff CurPlayer = CheckedOutPannals[player];

        CheckedoutChars.Remove(CurPlayer.SelectedChar);
        CurPlayer.setReady(false);
        CurPlayer.Pannal.transform.GetChild(1).gameObject.SetActive(false);
    }
Example #9
0
 void Start()
 {
     player      = GetComponent <PlayerStuff>();
     dia         = PlayerStuff.hud.GetComponentInChildren <DialogCentre>();
     addMoney    = player.tablePlayer.GetComponentsInChildren <Text>(true)[2];
     tableMoney  = player.tablePlayer.GetComponentsInChildren <Text>()[1];
     MoneyAmount = Assets.New_scripts.GameSettings.startMoney;
 }
Example #10
0
 private void Start()
 {
     player = GetComponent <PlayerStuff>();
     hud    = GameObject.Find("HUD").GetComponentInChildren <hudChange>();
     dia    = hud.GetComponentInChildren <DialogCentre>(true);
     if (cardMenu == null)
     {
         cardMenu = hud.GetComponentInChildren <CardMenu>();
     }
 }
Example #11
0
        private void Die()
        {
            PlayerStuff.AddMoney(reward);

            var deathEffect = Instantiate(bugDeathEffect, transform.position, Quaternion.identity);

            Destroy(deathEffect, 3f);

            Destroy(gameObject);
        }
Example #12
0
        public void TakeDamage(int damage)
        {
            health -= damage;
            healthBar.fillAmount = health / startHealth;

            if (health <= 0)
            {
                PlayerStuff.IncrementEnemiesKilled();
                Die();
            }
        }
Example #13
0
    public void UpgradeCard()
    {
        PlayerStuff player = GetComponent <Turn>().player;
        Card        card   = player.targetCard;

        if (!player.upgradeMade)
        {
            card.Upgrade();
            player.upgradeMade = true;
        }
    }
    public void TrySelectleft(PlayerInput player)
    {
        PlayerStuff curPlayer = CheckedOutPannals[player];

        if (!curPlayer.Ready && curPlayer.SelectedChar > 0)
        {
            deselectImage(curPlayer.Pannal.transform.GetChild(2).GetChild(curPlayer.SelectedChar).GetComponentInChildren <Image>());
            curPlayer.SelectedChar--;
            selectImage(curPlayer.Pannal.transform.GetChild(2).GetChild(curPlayer.SelectedChar).GetComponentInChildren <Image>());
        }
    }
    public void ReadyPlayer(PlayerInput player)
    {
        PlayerStuff CurPlayer = CheckedOutPannals[player];

        if (!CheckedoutChars.ContainsKey(CurPlayer.SelectedChar))
        {
            CheckedoutChars.Add(CurPlayer.SelectedChar, true);
            CurPlayer.setReady(true);
            CurPlayer.Pannal.transform.GetChild(1).gameObject.SetActive(true);
        }
    }
Example #16
0
    internal void EnableBancruptMenu(PlayerStuff player)
    {
        bancruptMenu.gameObject.SetActive(true);
        bancruptMenu.GetComponentsInChildren <Button>()[0].onClick.AddListener(() => bancruptMenu.gameObject.SetActive(false));

        bancruptMenu.GetComponentsInChildren <Button>()[1].onClick.AddListener(() =>
        {
            player.Bancrupt();
            bancruptMenu.gameObject.SetActive(false);
        });
    }
Example #17
0
 void Start()  /**/
 {
     if (level)
     {
         zoneName = level.zoneName;
         act      = level.act;
         next     = level.next;
     }
     s            = Instantiate(spawnOnStart).GetComponent <PlayerStuff>();
     h            = Instantiate(Game.hudStyle, Vector3.zero, Quaternion.identity, s.canvas.transform).GetComponent <HUD>();
     current      = this;
     s.player.hud = h;
     h.player     = s.player;
 }
Example #18
0
    public void Buy(Card card, PlayerStuff player)
    {
        Property prop = player.GetComponent <Property>();

        if (player.gameObject.GetComponent <Money>().Transaction(card.cost))
        {
            print("Опреция завершена");

            prop.AddCard(card);
        }
        else
        {
            print("Недостаточно стредств");
        }
    }
Example #19
0
        public Won(PlayerStuff.Player.EPlayerViewportPosition playerIndex, bool won)
        {
            infoText = new Text("03", new Vector2(0, 0));
            infoText.setIndividualScale(2);
            infoText.setPosition(new Vector2(Settings.getResolutionX() / 2 - infoText.getWidth() / 2, Settings.getResolutionY() - infoText.getHeight()));
            elapsedTime = 0;

            switch (playerIndex)
            {

                case PlayerStuff.Player.EPlayerViewportPosition.fullscreen:
                    if(won)
                       {
                           infoText.setColor(Color.Black);
                         background = new Icon(new Microsoft.Xna.Framework.Vector2(0, 0), "Textures/WinScreens/youWin");
                       }
                    else
                    {
                        infoText.setColor(Color.White);
                        background = new Icon(new Microsoft.Xna.Framework.Vector2(0, 0), "Textures/WinScreens/youLose");
                    }
                    break;
                case PlayerStuff.Player.EPlayerViewportPosition.left:
                    infoText.setColor(Color.White);
                    background = new Icon(new Microsoft.Xna.Framework.Vector2(0, 0), "Textures/WinScreens/player1Win");
                    break;
                case PlayerStuff.Player.EPlayerViewportPosition.right:
                    infoText.setColor(Color.White);
                    background = new Icon(new Microsoft.Xna.Framework.Vector2(0, 0), "Textures/WinScreens/player2Win");
                    break;
                case PlayerStuff.Player.EPlayerViewportPosition.topLeft:
                    infoText.setColor(Color.White);
                    background = new Icon(new Microsoft.Xna.Framework.Vector2(0, 0), "Textures/WinScreens/player1Win");
                    break;
                case PlayerStuff.Player.EPlayerViewportPosition.botLeft:
                    infoText.setColor(Color.White);
                    background = new Icon(new Microsoft.Xna.Framework.Vector2(0, 0), "Textures/WinScreens/player2Win");
                    break;
                case PlayerStuff.Player.EPlayerViewportPosition.topRight:
                    infoText.setColor(Color.White);
                    background = new Icon(new Microsoft.Xna.Framework.Vector2(0, 0), "Textures/WinScreens/player3Win");
                    break;
                case PlayerStuff.Player.EPlayerViewportPosition.botRight:
                    infoText.setColor(Color.White);
                    background = new Icon(new Microsoft.Xna.Framework.Vector2(0, 0), "Textures/WinScreens/player4Win");
                    break;
            }
        }
Example #20
0
 public override void Tick()
 {
     if (!EnemyIsAlive() && waves.nextWave >= waves.waves.Length)
     {
         PlayerStuff.SetGameWon();
     }
     else
     if (!EnemyIsAlive())
     {
         waves.SetState(new SpawningState(waves, instance));
     }
     else
     {
         return;
     }
 }
Example #21
0
    // Update is called once per frame
    void Update()
    {
        if (gameOver)
        {
            return;
        }

        if (PlayerStuff.GetHealth() <= 0)
        {
            EndGame();
        }
        if (PlayerStuff.GetGameWon())
        {
            GameWonScreen();
        }
    }
Example #22
0
    internal void ChanceCard()
    {
        PlayerStuff player = turn.player;

        dia = hud.GetComponentInChildren <DialogCentre>(true);

        switch (UnityEngine.Random.Range(0, 4))
        {
        case 0: dia.ShowMessage("Игрок " + player.name + " находит мелочь на дороге. +684$"); player.GetComponent <Money>().Transaction(-684); player.EndTurn(); break;

        case 1: dia.ShowMessage("Игрок " + player.name + " замечает несколько купюр в зимней куртке. +980$"); player.GetComponent <Money>().Transaction(-980); player.EndTurn(); break;

        case 2: dia.ShowMessage("Игрок " + player.name + " выигрывает региональный конкурс предпринимателей. +1500$"); player.GetComponent <Money>().Transaction(-1500); player.EndTurn(); break;

        case 3: dia.ShowMessage("Игрок " + player.name + " проливает чай на свой компьютер. Починка 1000$"); player.targetCard.cost = 1000; ShowPay(); break;

        case 4: dia.ShowMessage("Игроку " + player.name + " пора отдохнуть. Поезка на море обойдется в 2000$"); player.targetCard.cost = 2000; ShowPay(); break;
        }
    }
Example #23
0
    public void EndTurn()
    {
        hud.HideAll();
        PlayerStuff tmp = turn.player;

        if (!dice)
        {
            turns       = 1;
            turn.player = nextPlayer;
        }
        else
        {
            turns++;
        }
        print("Конец хода у игрока " + tmp.name + ". Сейчас будет " + turns + " ход у игрока " + turn.player.name);
        hud.ShowRoll();
        upgradeMade = false;
        dice        = false;
    }
Example #24
0
    public void Buy()
    {
        PlayerStuff player = GetComponent <Turn>().player;
        Card        card   = player.targetCard;
        Property    prop   = player.GetComponent <Property>();

        if (player.gameObject.GetComponent <Money>().Transaction(card.cost))
        {
            print("Опреция завершена");

            player.GetComponent <Property>().AddCard();

            player.EndTurn();
        }
        else
        {
            print("Недостаточно стредств");
        }
    }
Example #25
0
    private void Start()
    {
        owner      = null;
        isMonopoly = false;
        hud        = GameObject.Find("HUD").GetComponentInChildren <hudChange>();
        upgLevel   = GetComponentInChildren <TextMesh>();
        if (canBuy)
        {
            costText      = GetComponentsInChildren <TextMesh>()[1];
            costText.text = _cost + "$";

            labelText      = GetComponentsInChildren <TextMesh>()[2];
            labelText.text = label;
            Color tmpColor = labelText.color;
            tmpColor.a      = 0f;
            labelText.color = tmpColor;
        }
        turn = GameObject.Find("players").GetComponent <Turn>();

        // Индексы монополий
        List <int> monopolyInds = new List <int> {
            0, 1, 2, 3, 4, 5, 6, 7, 15
        };

        if (monopolyInds.Contains(index))
        {
            canBuy = true;
        }
        //
        try
        {
            anim = GetComponent <Animator>();
        }
        catch (System.Exception)
        {
            anim = null;
        }

        trade = hud.GetComponentInChildren <Trade>();
    }
        private IEnumerator SpawnEnemies()
        {
            if (WaveToSpawn == null)
            {
                yield break;
            }

            PlayerStuff.IncrementWavesSurvived();

            System.Random rand = new System.Random();
            Debug.Log("Spawning wave " + WaveToSpawn.number + " with " + WaveToSpawn.enemyCount + " enemies!");

            AbstractBug nextBug;

            for (int i = 0; i < WaveToSpawn.enemyCount; i++)
            {
                nextBug = WaveToSpawn.bugs[rand.Next(0, WaveToSpawn.bugs.Count)];
                SpawnEnemy(nextBug);
                yield return(new WaitForSeconds(WaveToSpawn.delayBetweenEnemies));

                alreadySpawnedEnemies++;
            }
            yield break;
        }
Example #27
0
 // Update is called once per frame
 void Update()
 {
     moneyText.text = "Money: " + PlayerStuff.GetMoney().ToString();
 }
Example #28
0
 private void startup(object sender, PlayerStuff stuff)
 {
     this.gameObject.AddComponent <Free>().giveStuff(stuff);
 }
 private void EndOfPath()
 {
     PlayerStuff.DecreaseHealth();
     //ExecuteEvents.Execute<IEnemyReachedEnd>(playerStuff.gameObject, null, (x, y) => x.OnEnemyReachedEnd());
     Destroy(gameObject);
 }
Example #30
0
 private void Awake()
 {
     instance = this;
 }
Example #31
0
 /* First thing that is called when the scene runs */
 void Awake()
 {
     /* Initialize the PlayerStuff structure through C++ wrapper function */
     _playerStuff = getPlayerStuff();
 }
Example #32
0
    void Start()
    {
        Assembly      thisAssembly = Assembly.GetExecutingAssembly();
        StringBuilder OutputText;

        OutputText = new StringBuilder();

        print("Start information");
        foreach (Type t in thisAssembly.GetTypes())
        {
            OutputText.AppendLine("\n FIELDS FOR:" + t.FullName + "\r\n");
            MemberInfo[]   Members    = t.GetMembers();
            FieldInfo[]    fields     = t.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
            PropertyInfo[] properties = t.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
            MethodInfo[]   methods    = t.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly);
            OutputText.Append(fields.Length);

            foreach (FieldInfo NextMember in fields)
            {
                if (NextMember.IsPublic)
                {
                    OutputText.AppendLine("\n\t" + NextMember.Name + "\tpublic\t" + NextMember.FieldType);
                }
                else
                {
                    OutputText.AppendLine("\n\t" + NextMember.Name + "\tprivate\t" + NextMember.FieldType);
                }
            }
            OutputText.Append("\nPROPERTIES FOR " + t.FullName + "\r\n");
            foreach (PropertyInfo NextMember in properties)
            {
                OutputText.AppendLine("\n\t" + NextMember.Name + "\tpublic\t" + NextMember.PropertyType + "\tget/set");
            }
            OutputText.Append("\n METHODS FOR " + t.FullName + "\r\n");
            foreach (MethodInfo NextMember in methods)
            {
                if (NextMember.IsPublic)
                {
                    OutputText.AppendLine("\n\t" + NextMember.Name + "\tpublic\t" + NextMember.ReturnType + "\t" + GetParamName(NextMember));
                }
                else
                {
                    OutputText.AppendLine("\n\t" + NextMember.Name + "\tprivate\t" + NextMember.ReturnType + "\t" + GetParamName(NextMember));
                }
            }
        }
        print(OutputText);
        using (FileStream fs = new FileStream(@"c:\Users\Nick\Desktop\info.txt", FileMode.Create
                                              ))
        {
            using (StreamWriter sw = new StreamWriter(fs))
            {
                sw.WriteLine(OutputText);
            }
        }
        print("End information");



        operations = GetComponent <Operations>();
        players    = new List <PlayerStuff>();

        for (int i = 0; i < GameSettings.NumberOfPlayers; i++)
        {
            var newPlayer = GameObject.Instantiate(prefabPlayer);
            newPlayer.name = names[i];
            newPlayer.GetComponent <PlayerStuff>().color = playerColors[i];
            newPlayer.transform.SetParent(transform);

            var newPanelPlayer = GameObject.Instantiate(prefabPanelPlayer);
            var texts          = newPanelPlayer.GetComponentsInChildren <Text>();
            texts[0].text = newPlayer.name;
            texts[1].text = newPlayer.GetComponent <Money>().MoneyAmount.ToString();
            newPanelPlayer.transform.SetParent(table.transform);
            newPanelPlayer.GetComponent <Image>().color        = playerColors[i];
            newPanelPlayer.GetComponent <TradeCenter>().player = newPlayer.GetComponent <PlayerStuff>();
            newPlayer.GetComponent <PlayerStuff>().tablePlayer = newPanelPlayer;

            players.Add(newPlayer.GetComponent <PlayerStuff>());
        }

        currentPlayerIndex = 0;
        player             = players[currentPlayerIndex];

        foreach (var item in players)
        {
            player          = players[++currentPlayerIndex % players.Count];
            item.nextPlayer = player;
        }
        hud.HideAll();

        hud.ShowRoll();
    }