Ejemplo n.º 1
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    //  Called when the player presses a button on the selection wheel with this world object linked to the button.
    /// </summary>
    /// <param name="buildingSlot">
    //  The building slot that instigated the selection wheel.
    //  (EG: If you're making a building, this is the building slot thats being used.)
    /// </param>
    public override void OnWheelSelect(BuildingSlot buildingSlot)
    {
        // Deselect the building slot
        buildingSlot.SetIsSelected(false);

        // Get player reference
        Player plyr = GameManager.Instance.Players[0];

        // Check if the player has enough resources to build the object
        if ((plyr.SuppliesCount >= this.CostSupplies) && (plyr.PowerCount >= this.CostPower))
        {
            // DO SOME SHIT BRO
        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    }
Ejemplo n.º 2
0
    /// <summary>
    //  Called when the player presses a button on the selection wheel with this world object linked to the button.
    /// </summary>
    /// <param name="buildingSlot">
    //  The building slot that instigated the selection wheel.
    //  (EG: If you're making a building, this is the building slot thats being used.)
    /// </param>
    public override void OnWheelSelect(BuildingSlot buildingSlot)
    {
        // Deselect the building slot
        buildingSlot.SetIsSelected(false);
        Debug.Log("Fog ability!");
        // Get player reference
        Player plyr = GameManager.Instance.Players[0];

        // Check if the player has enough resources to build the object
        if ((plyr.SuppliesCount >= this.CostSupplies) && (plyr.PowerCount >= this.CostPower))
        {
            Instantiate(FogSpotterObject, plyr._HUD.FindHitPoint(), new Quaternion());
        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    }
Ejemplo n.º 3
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    //  Called when the player presses a button on the selection wheel with this world object
    //  linked to the button.
    /// </summary>
    /// <param name="buildingSlot">
    //  The building slot that instigated the selection wheel.
    //  (EG: If you're making a building, this is the building slot thats being used.)
    /// </param>
    public override void OnWheelSelect(BuildingSlot buildingSlot)
    {
        base.OnWheelSelect(buildingSlot);

        // Get reference to the newly cloned building
        if (_ClonedWorldObject != null)
        {
            // Reset building time
            if (SceneManager.GetSceneByName("TutorialScene") == SceneManager.GetActiveScene())
            {
                _CurrentBuildTime = BuildingTimeTutorial;
            }
            else
            {
                _CurrentBuildTime = BuildingTime;
            }

            // Update building slot team for the outline colouring
            Building building = _ClonedWorldObject.GetComponent <Building>();
            building.AttachedBuildingSlot      = buildingSlot;
            building.AttachedBuildingSlot.Team = _ClonedWorldObject.Team;

            // Update building slot ref with building
            buildingSlot.SetBuildingOnSlot(building);
            buildingSlot.SetIsSelected(false);
            buildingSlot.SetOutlineVisibility(false);

            Base     attachedBase     = buildingSlot.AttachedBase;
            Building attachedBuilding = buildingSlot.AttachedBuilding;

            // Add the building to the buildingslot's building's queue (i know, confusing right?)
            if (buildingSlot.ObjectsCreatedAreQueued)
            {
                // Add to attached base list (if valid)
                if (attachedBase != null)
                {
                    attachedBase.AddBuildingToList(building);
                    ///attachedBase.AddToQueue(building);

                    // Get rally point reference
                    if (attachedBase.GetRallyPoint() == null)
                    {
                        attachedBase.CreateRallyPoint();
                    }
                    building._Rallypoint = attachedBase.GetRallyPoint();

                    // Add to queue wrapper
                    if (building._BuildingQueueUI != null)
                    {
                        if (!UI_BuildingQueueWrapper.Instance.ContainsQueue(building._BuildingQueueUI))
                        {
                            UI_BuildingQueueWrapper.Instance.AddNewQueue(building._BuildingQueueUI);
                        }
                        building._BuildingQueueUI.transform.SetParent(UI_BuildingQueueWrapper.Instance.QueueListTransform);
                        building._BuildingQueueUI.gameObject.SetActive(true);
                    }
                    else
                    {
                        building.CreateQueueWidget();
                    }
                }

                // Add to attached building list (if valid)
                if (attachedBuilding != null && attachedBase == null)
                {
                    if (!attachedBuilding.RemoveFromQueue(building))
                    {
                        attachedBuilding.AddToQueue(building);
                    }

                    // Add to queue wrapper
                    if (building._BuildingQueueUI != null)
                    {
                        if (!UI_BuildingQueueWrapper.Instance.ContainsQueue(building._BuildingQueueUI))
                        {
                            UI_BuildingQueueWrapper.Instance.AddNewQueue(building._BuildingQueueUI);
                        }
                        building._BuildingQueueUI.transform.SetParent(UI_BuildingQueueWrapper.Instance.QueueListTransform);
                        building._BuildingQueueUI.gameObject.SetActive(true);
                    }
                    else
                    {
                        building.CreateQueueWidget();
                    }
                }

                // Send message to match feed
                MatchFeed.Instance.AddMessage(string.Concat(ObjectName, " added to queue."));
            }

            // Skip the queue process and start building the object immediately
            else   /// (!buildingSlot.ObjectsCreatedAreQueued)

            // Remove it from the base/building's queue (WorldObject class adds it at the start!)
            {
                if (attachedBase != null)
                {
                    attachedBase.RemoveFromQueue(building);
                }
                if (attachedBuilding != null)
                {
                    attachedBuilding.RemoveFromQueue(building);
                }

                // Start building the object
                building.StartBuildingObject();
            }

            // Set rally point
            if (buildingSlot.AttachedBase != null)
            {
                _Rallypoint = buildingSlot.AttachedBase.GetRallyPoint();
            }
        }

        // Play building started sound
        SoundManager.Instance.PlaySound("SFX/_SFX_Building", 1f, 1f);
    }
Ejemplo n.º 4
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    //
    /// </summary>
    /// <param name="other"></param>
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag != "Ground" && other.gameObject.layer != LayerMask.NameToLayer("Ignore Raycast"))
        {
            // Not holding LEFT CONTROL and LEFT SHIFT
            if (!Input.GetKey(KeyCode.LeftControl))
            {
                if (!Input.GetKey(KeyCode.LeftShift))
                {
                    // Deselect any objects that are currently selected
                    foreach (var obj in _Player.SelectedWorldObjects)
                    {
                        obj.SetIsSelected(false);
                    }
                    _Player.SelectedWorldObjects.Clear();
                    foreach (var obj in _Player.SelectedUnits)
                    {
                        obj.SetIsSelected(false);
                    }
                    _Player.SelectedUnits.Clear();

                    if (_Player.SelectedBuildingSlot != null)
                    {
                        _Player.SelectedBuildingSlot.SetIsSelected(false);
                        _Player.SelectedBuildingSlot = null;
                    }
                }
            }

            // Cast hit object to selectable objects
            Base         baseObj      = null;
            Building     buildingObj  = null;
            BuildingSlot buildingSlot = null;
            Unit         unit         = null;
            WorldObject  worldObj     = null;

            baseObj      = other.gameObject.GetComponentInParent <Base>();
            buildingSlot = other.gameObject.GetComponent <BuildingSlot>();
            worldObj     = other.gameObject.GetComponentInParent <WorldObject>();

            // Left clicking on something attached to a base
            if (baseObj != null)
            {
                buildingObj = other.gameObject.GetComponent <Building>();

                // Left clicking on a base
                if (buildingObj == null && buildingSlot == null)
                {
                    // Matching team
                    if (baseObj.Team == _Player.Team)
                    {
                        // Add selection to list
                        _Player.SelectedWorldObjects.Add(baseObj);
                        baseObj.SetPlayer(_Player);
                        baseObj.SetIsSelected(true);
                        baseObj.OnSelectionWheel();
                    }
                }

                // Left clicking on a building
                if (buildingObj != null)
                {
                    if (buildingSlot == null)
                    {
                        // Matching team
                        if (buildingObj.Team == _Player.Team)
                        {
                            // Add selection to list
                            _Player.SelectedWorldObjects.Add(buildingObj);
                            buildingObj.SetPlayer(_Player);
                            buildingObj.SetIsSelected(true);
                            buildingObj.OnSelectionWheel();
                        }
                    }
                }

                // Left clicking on a building slot
                if (buildingSlot != null)
                {
                    // Empty building slot
                    if (buildingSlot.GetBuildingOnSlot() == null)
                    {
                        // Matching team
                        if (buildingSlot.AttachedBase.Team == _Player.Team)
                        {
                            _Player.SelectedBuildingSlot = buildingSlot;
                            buildingSlot.SetPlayer(_Player);
                            buildingSlot.SetIsSelected(true);
                        }
                    }

                    // Builded slot
                    else
                    {
                        // Matching team
                        if (buildingSlot.GetBuildingOnSlot().Team == _Player.Team)
                        {
                            // Add selection to list
                            _Player.SelectedWorldObjects.Add(buildingSlot.GetBuildingOnSlot());
                            buildingSlot.GetBuildingOnSlot().SetPlayer(_Player);
                            buildingSlot.GetBuildingOnSlot().SetIsSelected(true);
                            buildingSlot.GetBuildingOnSlot().OnSelectionWheel();
                        }
                    }
                }
            }

            // Left clicking on something NOT attached to a base
            else
            {
                buildingObj = other.gameObject.GetComponentInParent <Building>();

                // Left clicking on a building
                if (buildingObj != null)
                {
                    if (baseObj == null && buildingSlot == null)
                    {
                        // Matching team
                        if (buildingObj.Team == _Player.Team)
                        {
                            // Add selection to list
                            _Player.SelectedWorldObjects.Add(buildingObj);
                            buildingObj.SetPlayer(_Player);
                            buildingObj.SetIsSelected(true);
                            buildingObj.OnSelectionWheel();
                        }
                    }
                }

                // Hit an AI object?
                unit = other.gameObject.GetComponentInParent <Unit>();

                // Left clicking on a unit
                if (unit != null)
                {
                    // Unit is active in the world
                    if (unit.GetObjectState() == Abstraction.WorldObjectStates.Active)
                    {
                        // Matching team
                        if (unit.Team == _Player.Team)
                        {
                            // Add selection to list
                            _Player.SelectedWorldObjects.Add(unit);
                            _Player.SelectedUnits.Add(unit);
                            unit.SetPlayer(_Player);
                            unit.SetIsSelected(true);
                        }
                    }
                }

                // Left clicking on a world object
                if (worldObj != null)
                {
                    if (buildingSlot == null && buildingObj == null && baseObj == null && unit == null)
                    {
                        // Add selection to list
                        _Player.SelectedWorldObjects.Add(worldObj);
                        worldObj.SetPlayer(_Player);
                        worldObj.SetIsSelected(true);
                    }
                }

                // Left clicking on a building slot
                if (buildingSlot != null)
                {
                    // Empty building slot
                    if (buildingSlot.GetBuildingOnSlot() == null)
                    {
                        _Player.SelectedBuildingSlot = buildingSlot;
                        buildingSlot.SetPlayer(_Player);
                        buildingSlot.SetIsSelected(true);
                    }

                    // Builded slot
                    else
                    {
                        // Matching team
                        if (buildingSlot.GetBuildingOnSlot().Team == _Player.Team)
                        {
                            // Add selection to list
                            _Player.SelectedWorldObjects.Add(buildingSlot.GetBuildingOnSlot());
                            buildingSlot.GetBuildingOnSlot().SetPlayer(_Player);
                            buildingSlot.GetBuildingOnSlot().SetIsSelected(true);
                            buildingSlot.GetBuildingOnSlot().OnSelectionWheel();
                        }
                    }
                }
            }
        }

        // Just clicked on the ground so deselect all objects
        else
        {
            _Player.DeselectAllObjects();
        }
    }