Пример #1
0
        private void PositionGhostUnits(Vector3 facingPoint, bool makeVisible)
        {
            Vector3 diff    = facingPoint - _previewPosition;
            float   heading = diff.getRadianAngle();

            /*Vector3 forward = new Vector3(Mathf.Cos(heading), 0, Mathf.Sin(heading));
             * int formationWidth = _selection.Count;// Mathf.CeilToInt(2 * Mathf.Sqrt(spawnList.Count));
             * float platoonDistance = 4 * PlatoonBehaviour.UNIT_DISTANCE;
             * var right = Vector3.Cross(forward, Vector3.up);
             * var pos = _previewPosition + platoonDistance * (formationWidth - 1) * right / 2f;*/

            List <Vector3> positions = Formations.GetLineFormation(
                _previewPosition, heading + Mathf.PI / 2, _selection.Count);
            List <GhostPlatoonBehaviour> ghosts = _selection.ConvertAll(
                x => x.GhostPlatoon);

            for (int i = 0; i < _selection.Count; i++)
            {
                ghosts[i].SetPositionAndOrientation(positions[i], heading);
            }

            if (makeVisible)
            {
                ghosts.ForEach(x => x.SetVisible(true));
            }
        }
Пример #2
0
        private void ProcessOrder(OrderData orderData)
        {
            switch (orderData.OrderType)
            {
            case OrderType.MOVE_ORDER:
                List <Vector3> destinations = Formations.GetLineFormation(
                    orderData.TargetPosition, orderData.Heading, orderData.Platoon.Units.Count);

                for (int i = 0; i < orderData.Platoon.Units.Count; i++)
                {
                    orderData.Platoon.Units[i]
                    .SetDestination(destinations[i], orderData.Heading, orderData.MoveCommandType);
                }

                return;

            case OrderType.FIRE_POSITION_ORDER:
                orderData.Platoon.Units
                .ForEach(u => u.SendFirePosOrder(orderData.TargetPosition));
                orderData.Platoon.PlayAttackCommandVoiceline();

                return;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #3
0
        /// <summary>
        ///     Activates all units, moving from ghost/preview mode to a real platoon.
        /// </summary>
        /// <param name="spawnCenter"></param>
        private void Activate(Vector3 spawnCenter)
        {
            Units.ForEach(x =>
            {
                x.GameObject.SetActive(true);
                //Networking.CommandConnection.Connection.CmdSpawnObject(x.GameObject);
            });

            _platoonLabel.AssociateToRealUnits(Units);

            IsInitialized = true;

            transform.position = spawnCenter;

            List <Vector3> positions = Formations.GetLineFormation(
                spawnCenter, GhostPlatoon.FinalHeading, Units.Count);

            Units.ForEach(u => u.WakeUp());
            for (int i = 0; i < Units.Count; i++)
            {
                Units[i].Teleport(
                    positions[i], GhostPlatoon.FinalHeading - Mathf.PI / 2);
            }

            OrderMovement(
                GhostPlatoon.transform.position,
                GhostPlatoon.FinalHeading,
                MoveCommandType.FAST);
            GhostPlatoon.SetVisible(false);

            MatchSession.Current.RegisterPlatoonBirth(this);
        }
Пример #4
0
    public override void ProcessWaypoint()
    {
        var destinations = Formations.GetLineFormation(Destination, Heading, platoon.Units.Count);

        platoon.Units.ForEach(x => x.SetUnitDestination(this));
        //platoon.Units.ConvertAll(x => x as Matchable<Vector3>).Match(destinations);
        //platoon.Units.ForEach(x => x.SetUnitFinalHeading(Heading));
    }
Пример #5
0
        private void UpdateGhostLocations()
        {
            List <Vector3> positions = Formations.GetLineFormation(
                transform.position, FinalHeading, _units.Count);

            for (int i = 0; i < _units.Count; i++)
            {
                _units[i].GetComponent <MovementComponent>()
                .Teleport(positions[i], Mathf.PI / 2 - FinalHeading);
            }
        }
Пример #6
0
        // Places the ghost units (unit silhouettes) in view of the player:
        public void PreviewPurchase(Vector3 center, Vector3 facingPoint)
        {
            Vector3 diff    = facingPoint - center;
            float   heading = diff.getRadianAngle();

            var positions = Formations.GetLineFormation(center, heading + Mathf.PI / 2, GhostPlatoons.Count);

            for (var i = 0; i < GhostPlatoons.Count; i++)
            {
                GhostPlatoons[i].SetOrientation(positions[i], heading);
            }
        }
Пример #7
0
    public void SetOrientation(Vector3 center, float heading)
    {
        FinalHeading       = heading;
        transform.position = center;

        var positions = Formations.GetLineFormation(center, heading, _units.Count);

        for (int i = 0; i < _units.Count; i++)
        {
            _units[i].GetComponent <UnitBehaviour>().SetOriginalOrientation(positions[i], Mathf.PI / 2 - heading, false);
        }
    }
Пример #8
0
        public void SetPositionAndOrientation(Vector3 center, float heading)
        {
            FinalHeading       = heading;
            transform.position = center;

            List <Vector3> positions = Formations.GetLineFormation(center, heading, _units.Count);

            for (int i = 0; i < _units.Count; i++)
            {
                _units[i].GetComponent <MovementComponent>()
                .Teleport(positions[i], Mathf.PI / 2 - heading);
            }
        }
Пример #9
0
        /// <summary>
        /// Places the ghost units (unit silhouettes) in view of the player.
        /// </summary>
        /// <param name="center"></param>
        /// <param name="facingPoint"></param>
        public void PreviewPurchase(Vector3 center, Vector3 facingPoint)
        {
            Vector3 diff    = facingPoint - center;
            float   heading = diff.getRadianAngle();

            List <Vector3> positions = Formations.GetLineFormation(
                center, heading + Mathf.PI / 2, PreviewPlatoons.Count);

            for (int i = 0; i < PreviewPlatoons.Count; i++)
            {
                PreviewPlatoons[i].SetGhostOrientation(positions[i], heading);
                PreviewPlatoons[i].ToggleGhostVisibility(true);
            }
        }
Пример #10
0
    public void Spawn(Vector3 center)
    {
        transform.position = center;
        var heading = GhostPlatoon.GetComponent <GhostPlatoonBehaviour>().FinalHeading;

        var positions = Formations.GetLineFormation(center, heading, Units.Count);

        for (int i = 0; i < Units.Count; i++)
        {
            Units[i].SetOriginalOrientation(positions[i], heading - Mathf.PI / 2);
        }

        Movement.BeginQueueing(false);
        Movement.GetDestinationFromGhost();
        Movement.EndQueueing();
        GhostPlatoon.SetVisible(false);

        Owner.Session.RegisterPlatoonBirth(this);
    }