Наследование: IInitializeSystem, IMultiReactiveSystem, ISetPool
Пример #1
0
    public void SetupOneCardAi()
    {
        IsStartAi.Subscribe(value =>
        {
            if (value)
            {
                Debug.Log("ai start");
                var cardIndex = 0;
                var playerId  = TurnSystem.GetInstance().PlayerNowTurn.Value;
                var isPut     = PlayerSystem.GetInstance().GetPlayerIsPutCard(playerId);

                Observable.Interval(TimeSpan.FromSeconds(0.5f))
                .TakeWhile(_ => RandomCard(playerId, ref cardIndex) >= 0)
                .Subscribe(i =>
                {
                    var card = PlayerSystem.GetInstance().GetPlayerCard(playerId, cardIndex);

                    PlayerSystem.GetInstance().PlayerPutCard(DeckTag.PUT_DECK, playerId, cardIndex, true);

                    RuleSystem.GetInstance().CheckSpecialCard(card, isPut);
                },
                           () =>
                {
                    IsStartAi.Value = false;
                    TurnSystem.GetInstance().EndTurn();
                });
            }
        });
    }
Пример #2
0
    // Start is called before the first frame update
    void Start()
    {
        //Here is to make sure things are setup properly.
        thisCard[0]         = CardDataBase.cardList[thisID];
        numberOfCardsInDeck = PlayerDeck.deckSize;

        canBeSummon = false;
        summoned    = false;

        drawX = 0;

        canAttack         = false;
        summoningSickness = true;

        enemy = GameObject.Find("EnemyHealth");

        targeting        = false;
        targetingEnemy   = false;
        thisIsASpellCard = false;

        fieldObject = GameObject.Find("Field");
        field       = fieldObject.GetComponent <CardsOnTheField>();

        canHeal = false;

        Ts = GameObject.Find("TurnSystem").GetComponent <TurnSystem>();
    }
Пример #3
0
    private void Awake()
    {
        Instance = this;

        //
        EndEnemyTurn();
    }
Пример #4
0
    void Update()
    {
        //Only Read Inputs if this is the currently active actionmanager
        if (m_Owner.OwnerID != 0)
        {
            return;
        }

        if (TurnSystem.Instance == null || !TurnSystem.HasTurn(m_Owner))
        {
            return;
        }
        if (Input.GetKeyDown(KeyCode.Backspace))
        {
            SkipTurn();
            return;
        }

        if (Input.GetMouseButtonDown(1))
        {
            if (currentAction != null && GetOwnerID() == 0)
            {
                SoundManager.PlayAtSourceTag("SoundSFXSource", "sfx_" + SoundManager.Presets.ability_cancel.ToString());
            }
            UnsetCurrentAction();
        }
    }
Пример #5
0
    public IEnumerator ShareCard(DeckTag deck, int cardNum, float shareDelay)
    {
        WaitForSeconds delay = new WaitForSeconds(shareDelay);

        int tempTurn = TurnSystem.GetInstance().GetNowTurnPlayerIndex();

        if (tempTurn < 0)
        {
            tempTurn = 0;
        }

        for (int i = 0; i < Players.Count; i++)
        {
            for (int j = 0; j < cardNum; j++)
            {
                Card card = DeckSystem.GetInstance().GetTopCardWithDeck(deck);

                if (tempTurn + i >= Players.Count)
                {
                    tempTurn -= Players.Count;
                }

                Players[tempTurn + i].AddPlayerCard(card);

                yield return(delay);
            }
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        GameObject player;

        startButton.SetActive(false);
        if (PhotonNetwork.IsConnected)
        {
            if (PhotonNetwork.CurrentRoom.PlayerCount > 1)
            {
                // setup players based on number of players?
            }
            if (NetworkedPlayer.LocalPlayerInstance == null)
            {
                // instantiate the networked prefabs
                player = PhotonNetwork.Instantiate(playerPrefab.name, transform.position, Quaternion.identity, 0);
            }
            if (PhotonNetwork.IsMasterClient)
            {
                startButton.SetActive(true);
                turnSystem = transform.gameObject.GetComponent <TurnSystem>();
                InitHexGrid();
            }
        }
        else
        {
            turnSystem = transform.gameObject.GetComponent <TurnSystem>();
            InitHexGrid();
            InitPlayers();
            ready = true;
        }
    }
Пример #7
0
 // Update is called once per frame
 void Update()
 {
     if (TurnSystem.HasTurn(this))
     {
         if (Input.GetKeyUp(KeyCode.Escape))
         {
             SelectAction(-1);
         }
         if (Input.GetKeyUp(KeyCode.Alpha1))
         {
             SelectAction(0);
         }
         if (Input.GetKeyUp(KeyCode.Alpha2))
         {
             SelectAction(1);
         }
         if (Input.GetKeyUp(KeyCode.Alpha3))
         {
             SelectAction(2);
         }
         if (Input.GetKeyUp(KeyCode.Alpha4))
         {
             SelectAction(3);
         }
         if (Input.GetKeyUp(KeyCode.Alpha5))
         {
             SelectAction(4);
         }
     }
 }
Пример #8
0
 private void Awake()
 {
     getBarInfo    = FindObjectOfType <GetBarInfo>();
     turnSystem    = FindObjectOfType <TurnSystem>();
     damageHandler = FindObjectOfType <DamageHandler>();
     gridGenerator = FindObjectOfType <EditedGridGenerator>();
 }
Пример #9
0
 private void Awake()
 {
     allSkills     = FindObjectOfType <AllSkills>();
     turnSystem    = FindObjectOfType <TurnSystem>();
     gridGenerator = FindObjectOfType <EditedGridGenerator>();
     getStats      = GetComponent <GetStats>();
 }
Пример #10
0
    public IEnumerator AttackTarget(TurnSystem currentBattle, GameObject[] playerUnits)
    {
        int        targetCode = Random.Range(0, playerUnits.Length);
        GameObject target     = playerUnits[targetCode];

        yield return(AttackTarget(currentBattle, target));
    }
Пример #11
0
    private void Awake()
    {
        drawableCards = Player.GetComponentInChildren <GetStats>().normalskills;
        uniqueCards   = Player.GetComponentInChildren <GetStats>().uniqueSkills;
        turnSystem    = FindObjectOfType <TurnSystem>();

        GameObject empty = new GameObject("place");

        for (int i = 0; i < maxCardCount; i++)
        {
            placePos = new Vector3(this.transform.position.x - (this.GetComponent <RectTransform>().rect.width / 2) + ((drawableCards[0].template.GetComponent <RectTransform>().rect.width + gap) * i) + drawableCards[0].template.GetComponent <RectTransform>().rect.width / 2, y_start, this.transform.position.z);

            var place = Instantiate(empty, placePos, this.transform.rotation);
            place.transform.SetParent(this.transform);
            places.Add(place);
        }

        if (startingCardCount <= maxCardCount)
        {
            for (int i = 0; i < startingCardCount; i++)
            {
                InstantiateCard(i);
            }
            lastIndex = startingCardCount;
        }
        else
        {
            for (int i = 0; i < maxCardCount; i++)
            {
                InstantiateCard(i);
            }
            lastIndex = maxCardCount;
        }
    }
Пример #12
0
        /// <summary>
        /// Load level asset, build scene, setup dependencies.
        /// </summary>
        public void LoadLevel(int levelNumber)
        {
            // Read RawAsset by its URI
            using (var stream = Content.OpenAsStream($"LVL{levelNumber}", StreamFlags.None))
                level = LevelReader.Read(stream);

            var actionController = Entity.GetOrCreate <ActionController>();
            var builder          = new LevelBuilder(Environment, Robot, Items, SoundLibrary);

            var scene = builder.Build(level, out var robot);

            this.Entity.Scene.Children.Add(scene);

            actionController.Robot = robot.Get <RobotController>();

            var robotBrain = Entity.GetOrCreate <RobotBrain>();

            robotBrain.actions = level.ActionPattern;
            robotBrain.Reset();

            var inputController = Entity.GetOrCreate <InputController>();

            inputController.userActions  = level.UserActions;
            inputController.MistakeSound = SoundLibrary.MistakeSound;

            Camera.Entity.Get <RobotCameraFollower>().Robot = robot;

            TurnSystem.Reset();
            TurnSystem.Enable(Entity.Scene);
            TurnSystem.RemainingTime = level.ActionPattern.Length * TurnSystem.TurnLength * 5;

            UIScript.inputController = inputController;
            UIScript.robotBrain      = robotBrain;
        }
Пример #13
0
        public void Test()
        {
            Container container = new Container();

            container.InitComponentComparers();

            container.MmConfig = MatchmakingTest.TestConfig;

            int count = 100;

            for (int i = 0; i < count; ++i)
            {
                int entityId = container.CreateEntity();
                container.AddWaitingComponent(entityId, 0);
            }

            var system = new TurnSystem();

            system.Execute(container);

            for (int i = 0; i < container.WaitingComponentsCount; ++i)
            {
                if (container.TryGetWaitingTurnFromIndex(i, out int turn))
                {
                    Assert.AreEqual(1, turn);
                }
            }
        }
Пример #14
0
 public override IEnumerator Defend()
 {
     Debug.Log("DEFEND!");
     TurnSystem.SetState(new EnemyTurn(TurnSystem));
     yield break;
     //return base.Defend();
 }
Пример #15
0
    public override IEnumerator Start()
    {
        Debug.Log("It's now the players turn");
        yield return(new WaitForSeconds(2));

        TurnSystem.SetState(new PlayerTurn(TurnSystem));
    }
Пример #16
0
    // Use this for initialization
    void Start()
    {
        stats                       = GetComponent <Stats>();
        treeList                    = GetComponent <Trees>();
        turnSystem                  = GetComponent <TurnSystem>();
        maxTurnText.text            = maxTurns.ToString();
        co2Force                    = trees.Count;
        gameTurnDuration            = 5f;
        turnCount                   = 0;
        doOnce                      = true;
        doOnce2                     = true;
        buildButtonBool             = true;
        mineMultiplier              = 160f;
        woodMultiplier              = 1.1f;
        happinessIncreaseMultiplier = .25f;
        happinessDecreaseMultiplier = .1f;

        //Resource Variables
        windmillEnergy      = .2f;
        windmillMultiplier  = 2.1f;
        solarEnergy         = 1f;
        solarPower          = .6f;
        factoryPower        = .5f;
        factoriesMultiplier = 1f;
        house2Multiplier    = 1f;
        co2Multiplier       = 1.5f;
    }
Пример #17
0
    private void ServerPacketParse(int length)
    {
        string msg = Encoding.UTF8.GetString(buffer, 2, length - 2);

        string[] text = msg.Split(':');

        if (text[0].Equals("CONNECT"))
        {
            UnityEngine.Debug.Log("connect");
        }
        else if (text[0].Equals("GUEST-ID"))
        {
            UnityEngine.Debug.Log("guest-login : "******"Guest" + text[1];
        }
        else if (text[0].Equals("GAMESTART"))
        {
            for (int i = 0; i < text.Length - 1; i++)
            {
                if (PlayerSystem.GetInstance().MyPlayerId.Equals(text[i + 1]))
                {
                    for (int j = 0; j < text.Length - 1; j++)
                    {
                        if (i + 1 >= text.Length)
                        {
                            i -= (text.Length - 1);
                        }
                        PlayerSystem.GetInstance().AddPlayer(PlayerTag.PLAYER_BOTTOM + j, text[1 + i], false);
                        TurnSystem.GetInstance().AddTurnPlayer(text[1 + i]);
                        i++;
                    }
                    break;
                }
            }

            TurnSystem.GetInstance().SetFirstTurn(text[1]);
            StartCoroutine(SceneSystem.GetInstance().NowScene.NextSceneAnimation());
        }
        else if (text[0].Equals("ADD-CARD"))
        {
            int cardNum = Convert.ToInt32(text[2]);
            PlayerSystem.GetInstance().PlayerAddCardWithDeck(DeckTag.DRAW_DECK, text[1], cardNum);
        }
        else if (text[0].Equals("PUT-CARD"))
        {
            int playerCardIndex = Convert.ToInt32(text[2]);
            //PlayerSystem.GetInstance().PlayerPutCard(DeckTag.PUT_DECK,text[1],playerCardIndex, 0.5f);
        }
        else if (text[0].Equals("NEXT-TURN"))
        {
            TurnSystem.GetInstance().NextTurn();
        }
        else if (text[0].Equals("GET-RANDOMSEED"))
        {
            int seed = Convert.ToInt32(text[1]);
            UnityEngine.Random.InitState(seed);
        }
    }
Пример #18
0
 private void Start()
 {
     source = GetComponent <AudioSource>();
     source.PlayOneShot(woosh);
     system      = GameObject.Find("TurnSystem").GetComponent <TurnSystem>();
     playerValue = GameObject.Find("PlayerCardValue").GetComponent <Text>();
     enemyValue  = GameObject.Find("EnemyCardValue").GetComponent <Text>();
 }
Пример #19
0
 void Awake()
 {
     endTurn    = GetComponentInChildren <Button>();
     turnSystem = FindObjectOfType <TurnSystem>();
     turnSystem.PlayerTurnStarted += UpdateUI;
     turnSystem.PlayerTurnStarted += EnableUI;
     turnSystem.PlayerTurnEnded   += DisableUI;
 }
Пример #20
0
        public void SomeoneWinTest()
        {
            TurnSystem.InitializeData();

            Assert.AreEqual(false, GameMechanics.SomeoneWin());

            GameMechanics.ResetGame();
        }
Пример #21
0
 public BattleSystem(GameSystem gameSystem, Canvas canvas)
 {
     this.gameSystem = gameSystem;
     battlePanel     = canvas.GetComponent <BattlePanel>();
     turnSystem      = new TurnSystem(battlePanel);
     canvas.enabled  = false;
     isBattle        = false;
 }
Пример #22
0
 public void BeginGame()
 {
     turnSystem = new TurnSystem(players, this);
     GenerateTargets();
     playerPoints = new int[players + 1];
     ServerSend.BeginGame();
     StartCoroutine(GameStartDelay());
 }
Пример #23
0
        public void MakingFieldsArrayTest4()
        {
            TurnSystem.InitializeData();

            FieldManager.MakeFieldsArray();

            Assert.AreEqual(GameObject.Find("Black (1)"), FieldManager.BlackFieldsBoard[0].GameObject);
        }
Пример #24
0
 // Start is called before the first frame update
 void Start()
 {
     currentIndex = 0;
     currentSkill = player.GetComponent <BattleTestPlayer>().skills[currentIndex];
     MoveIndicator(new Vector2Int(currentIndex % 2, (currentIndex - minRenderedIndex) / 2));
     RenderMenuItems(currentIndex);
     turn = GameObject.FindGameObjectWithTag("Box").GetComponent <TurnSystem>();
 }
Пример #25
0
        public void MakingFieldsArrayTest3()
        {
            TurnSystem.InitializeData();

            FieldManager.MakeFieldsArray();

            Assert.AreEqual(3, FieldManager.BlackFieldsBoard[35].State);
        }
 private void OnTriggerEnter2D(Collider2D collision)
 {
     collision.SendMessage("hitByProjectile", SendMessageOptions.DontRequireReceiver);
     TurnSystem.swapTurn();
     randomiseWind();
     playerTurnText.text = PlayerTurnToText();
     destroyThis();
 }
    public void ReplaceTurnSystem(TurnSystem newValue)
    {
        var index     = GameComponentsLookup.TurnSystem;
        var component = CreateComponent <TurnSystemComponent>(index);

        component.value = newValue;
        ReplaceComponent(index, component);
    }
Пример #28
0
    //Start is called before the first frame update
    void Start()
    {
        //Assign checkers(gameobjects) and fields(gameobjects) to Checker(class) and Field(class) array,
        TurnSystem.InitializeData();

        //Start first turn, make first player clickable, second player unclickable etc.
        TurnSystem.StartGame();
    }
Пример #29
0
 private void Awake()
 {
     gameManager = FindObjectOfType <GameManager>();
     stats       = gameManager.GetComponent <Stats>();
     occupance   = this.GetComponent <Occupance>();
     turnSystem  = gameManager.GetComponent <TurnSystem>();
     gameManager.trees.Add(this.gameObject);
     woodCounter = occupance.maximumOccupanceAmount;
 }
Пример #30
0
    public int GetCurrentTurnCost()
    {
        if (TurnSystem.HasTurn(this))
        {
            return(CrumbleTurnCost);
        }

        return(0);
    }