Example #1
0
        public void ProcessUserInput()
        {
            if (!EventSystem.current.IsPointerOverGameObject())
            {
                var offsetVector = new Vector3(0, 0, 1);
                if (Input.GetMouseButtonDown(0))
                {
                    var worldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    var coll       = Physics2D.OverlapCircle(worldPoint, 0.5f, LayerMask.GetMask("PlayerFlags"));

                    if (coll)
                    {
                        if (currentlySelectedPlayer != null)
                        {
                            currentlySelectedPlayer.GetComponent <SpriteRenderer>().color = Color.white;
                        }
                        currentlySelectedPlayer = coll.GetComponent <BattlePlayer>();
                        currentlySelectedPlayer.GetComponent <SpriteRenderer>().color = Color.green;
                    }
                    else
                    {
                        if (currentlySelectedPlayer != null)
                        {
                            currentlySelectedPlayer.GetComponent <SpriteRenderer>().color = Color.white;
                        }
                        currentlySelectedPlayer = null;
                    }
                }
                if (battleStarted)
                {
                    if (Input.GetMouseButton(0) && currentlySelectedPlayer != null)
                    {
                        var worldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);

                        currentlySelectedPlayer.transform.position = (Vector2)worldPoint;
                    }
                }
            }
        }
Example #2
0
        private WarriorController CreateNewWarrior(Vector2 pos, StructureOfWarrior str, int team, NeuralAI ai, BattlePlayer pla)
        {
            var newObj = Instantiate(warrPref, warriorsParent.transform);

            var scrpt = newObj.GetComponent <WarriorController>();

            scrpt.Initialize(pos, str, team, ai, pla);

            return(scrpt);
        }