public void Initialize(Vector2 pos, StructureOfWarrior str, int team, NeuralAI ai, APlayerController pla)
        {
            currentAction = new Actions.IdleAction();
            sprRend       = GetComponent <SpriteRenderer>();

            transform.position = pos;

            playerOwner = pla;

            this.ai       = ai;
            this.team     = team;
            bloodMax      = str.blood;
            speed         = HelperConstants.speedMultOfWa;
            rotationSpeed = HelperConstants.warriorRotationSpeed;
            isShooter     = true;

            positionsDuringSomeTime = new Helpers.Deque <Vector2>(3);//TODO: magic number

            stats = new Statistics();
            //TODO: add limbs

            rigidbody2d = GetComponent <Rigidbody2D>();

            angles = new List <int>();

            #region Calculate angles

            Debug.Assert(raycastSensors % 2 == 1, "amount of sensors is too even");
            var mul = 0;
            for (int i = 0; i < raycastSensors; i++)
            {
                if (i % 2 == 0)
                {
                    angles.Add(90 - diffBetwSensorsInDeg * mul);
                }
                if (i % 2 == 1)
                {
                    mul += 1;
                    angles.Add(90 + diffBetwSensorsInDeg * mul);
                }
            }

            #endregion Calculate angles

            Revive(pos);
        }
        public WarriorController CreateNewWarrior(Vector2 pos, StructureOfWarrior str, int team, NeuralAI ai, PlayerController pla)
        {
            var newObj = Instantiate(warrPref, warriorsParent.transform);

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

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

            scrpt.rigidbody2d.rotation = UnityEngine.Random.Range(-180, 180);//TODO: fix this; implement random angle

            return(scrpt);
        }
예제 #3
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);
        }