Пример #1
0
        public BuyTransaction(UnitType type, PlayerData owner)
        {
            UnitType = type;
            Owner    = owner;

            _smallestPlatoonSize   = MIN_PLATOON_SIZE;
            _ghostPlatoonBehaviour =
                GhostPlatoonBehaviour.Build(type, owner, _smallestPlatoonSize);

            GhostPlatoons = new List <GhostPlatoonBehaviour>();
            GhostPlatoons.Add(_ghostPlatoonBehaviour);
        }
Пример #2
0
        public void AddUnit()
        {
            if (_smallestPlatoonSize < MAX_PLATOON_SIZE)
            {
                GhostPlatoons.Remove(_ghostPlatoonBehaviour);
                _ghostPlatoonBehaviour.Destroy();

                _smallestPlatoonSize++;
                _ghostPlatoonBehaviour =
                    GhostPlatoonBehaviour.Build(UnitType, Owner, _smallestPlatoonSize);
                GhostPlatoons.Add(_ghostPlatoonBehaviour);
            }
            else
            {
                // If all platoons in the transaction are max size, we add a new one and update the size counter:
                _smallestPlatoonSize   = MIN_PLATOON_SIZE;
                _ghostPlatoonBehaviour = GhostPlatoonBehaviour.Build(UnitType, Owner, _smallestPlatoonSize);
                GhostPlatoons.Add(_ghostPlatoonBehaviour);
            }
        }
Пример #3
0
    public void Initialize(UnitType t, PlayerData owner, int n)
    {
        Type  = t;
        Owner = owner;

        var iconInstance = Instantiate(Resources.Load <GameObject>("Icon"), transform);

        Icon           = iconInstance.GetComponent <IconBehaviour>();
        Icon.BaseColor = Owner.Team.Color;

        var unitPrefab = Owner.Session.Factory.FindPrefab(t);

        for (int i = 0; i < n; i++)
        {
            var unitInstance =
                Owner.Session.Factory.MakeUnit(unitPrefab, Owner.Team.Color);
            var unitBehaviour = unitInstance.GetComponent <UnitBehaviour>();
            unitBehaviour.SetPlatoon(this);
            Units.Add(unitBehaviour);

            var collider = unitInstance.GetComponentInChildren <BoxCollider>();
            collider.enabled = true;
        }

        BuildModules(t);

        if (t == UnitType.AFV)
        {
            var ghost = GhostPlatoonBehaviour.Build(UnitType.Infantry, owner, n);
            Transporter.SetTransported(ghost.GetRealPlatoon());
            ghost.SetOrientation(100 * Vector3.down, 0);
            ghost.SetVisible(false);
        }

        Movement.SetDestination(Vector3.forward);

        Icon.SetSource(Units);

        IsInitialized = true;
    }
Пример #4
0
        public void BuildUnit(UnitType t)
        {
            var behaviour = GhostPlatoonBehaviour.Build(t, _localPlayer, 4);

            _currentBuyTransaction.GhostPlatoons.Add(behaviour);
        }