/// <summary>
    /// If a commander leaves a zone while another is tweening towards it,
    /// the one tweening will have a "wrong" destination and might
    /// overlap with another commander, so we adjust the moving commanders'
    /// destinations. (This is only for cmder-adjusted tweens)
    /// </summary>
    /// <param name="spotWithChanges"></param>
    public void AdjustTweensThatTargetZone(ZoneSpot spotWithChanges)
    {
        int adjustmentCount = 1;
        int cmdersInSpot    = GameController.GetCommandersInZone(spotWithChanges.data as Zone).Count;

        foreach (TransformTween tween in activeTweens)
        {
            if (!tween.cmderAdjusted)
            {
                continue;
            }
            if (tween.destSpot == spotWithChanges)
            {
                tween.destPos = spotWithChanges.GetGoodSpotForCommander(
                    cmdersInSpot - adjustmentCount);
                adjustmentCount++;
            }
        }
    }
Example #2
0
    void Update()
    {
        if (GameInterface.openedPanelsOverlayLevel != 0)
        {
            return;
        }

        if (Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out hit, 100, 1 << 8))
        {
            ZoneSpot hitSpotScript = hit.transform.GetComponent <ZoneSpot>();
            if (allowedSpots.Contains(hitSpotScript))
            {
                //select zone if no zone was already selected
                curHoveredValidZone = hitSpotScript;
                cmderBlueprint.gameObject.SetActive(true);
                cmderBlueprint.position = hitSpotScript.GetGoodSpotForCommander();
                cmderBlueprint.Rotate(Vector3.up * Time.deltaTime * 100);                 //just a little rotation to make it prettier haha
            }
            else
            {
                curHoveredValidZone = null;
                cmderBlueprint.gameObject.SetActive(false);
            }
        }
        else
        {
            curHoveredValidZone = null;
            cmderBlueprint.gameObject.SetActive(false);
        }

        if (Input.GetButtonDown("Select"))
        {
            if (curHoveredValidZone != null)
            {
                NewCmderPhaseMan.OrderPlaceNewCmder((curHoveredValidZone.data as Zone).ID, GameModeHandler.instance.curPlayingFaction);
                actionOnSpotSelect();
                enabled = false;
            }
        }
    }