Inheritance: MonoBehaviour
Exemplo n.º 1
0
    private void DeselectUnits()
    {
        selectedObj = null;
        UI.CloseAllPanels();
        for (int i = 0; i < selectedObjects.Count; i++)
        {
            // Grabs all objects in selected array and deselects them
            selectedInfo          = selectedObjects[i].GetComponent <UnitSelection>();
            selectedInfo.selected = false;
        }
        selectedObjects.Clear();
        GameObject[] selectedIndicators = GameObject.FindGameObjectsWithTag("SelectedIndicator");
        if (selectedIndicators.Length > 0)
        {
            // UnitSelection indicators
            for (int j = 0; j < selectedIndicators.Length; j++)
            {
                // Turns the unit UnitSelection indicator off
                selectedIndicators[j].transform.gameObject.SetActive(false);

                // Deselects the unit
                if (selectedIndicators[j].transform.parent.GetComponent <UnitSelection>())
                {
                    selectedIndicators[j].transform.parent.GetComponent <UnitSelection>().selected = false;
                }
            }
        }

        isSelected = false;
    }
Exemplo n.º 2
0
    void OnTriggerEnter(Collider other)
    {
        print("Trigger Enter Triggered. Other is: " + other.ToString());
        if (other.gameObject != null)
        {
            //If the object we're colliding with is a unitSelection bubble... - Moore
            UnitSelection usScript = other.transform.parent.GetComponent <UnitSelection>();
            if (usScript != null)
            {
                //Then we add ourselves to the selection and start following the player. But only if we're not a player.
                if (shipType != ShipType.Alpha && shipType != ShipType.Node)
                {
                    CommandHandler.OnCommand += HandleCommandEvent;
                    UnitSelection.OnDeselect += HandleDeselectEvent;
                    isSelected = true;
                    state      = State.FollowPlayer;
                    UpdateStatusIndicator();
                }
            }

            //If the object we're colliding with is a Resonator AoE bubble... - Moore
            ResonatorEffectAreaBehavior reab = other.GetComponent <ResonatorEffectAreaBehavior>();
            if (reab != null)
            {
                print("Trigger Entered. 'Other' is: " + reab.ToString());
                reab.OnResonanceChange += SetRateModifer;
                print(rateModifier);
            }
        }
    }
Exemplo n.º 3
0
 void Awake()
 {
     groundMask    = LayerMask.GetMask("Ground");
     moveCommand   = GetComponent <MoveCommand>();
     unitSelection = GetComponent <UnitSelection>();
     command       = moveCommand.MoveUnits;
 }
Exemplo n.º 4
0
 public RectanglePattern(Point location, UnitSelection selection, int width, int spacing, int orientation)
     : base(location, selection)
 {
     this.width = width;
     this.spacing = spacing;
     this.orientation = orientation;
 }
Exemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        var numberOfColliders = collidedObjects.Count;

        if (numberOfColliders > 0)
        {
        }
        if (availableResource <= 0)
        {
            // Need to add isGathering = false
            foreach (Collider collidedObject in collidedObjects)
            {
                UnitController unit = collidedObject.gameObject.GetComponent <UnitController>();
                UnitSelection  unitUnitSelection = collidedObject.gameObject.GetComponent <UnitSelection>();
                if (unit)
                {
                    if (unit.unitType == "Worker")
                    {
                        unitUnitSelection.isGathering = false;
                    }
                }
            }
            Destroy(gameObject);
        }
    }
 void Select()
 {
     if (currentCharacter == null)
     {
         units[highlightedCharacter].Select(true);
         slots[highlightedCharacter].Select(true);
         descriptionMenu.SetCharacter(highlightedCharacter);
         characterMenu.SetCharacter(highlightedCharacter);
     }
     else
     {
         units[currentCharacter].Select(true);
         slots[currentCharacter].Select(true);
         descriptionMenu.SetCharacter(currentCharacter);
         characterMenu.SetCharacter(currentCharacter);
         selectedUnit = units[currentCharacter];
         //fade out other units
         foreach (UnitSelection u in units.Values)
         {
             if (u == selectedUnit)
             {
                 continue;
             }
             u.SetAlphaMoving(0f);
             u.SetLightMoving(0f);
             u.SetRaycast(false);
         }
         //move unit to center
         selectedUnit.SetPositionMoving(center.anchoredPosition);
     }
     descriptionMenu.gameObject.SetActive(true);
 }
Exemplo n.º 7
0
    IEnumerator VillagerSpawn()
    {
        isTraining     = true;
        selectedObj    = inputScript.selectedObj;
        buildingScript = selectedObj.GetComponent <BuildingController>();
        spawnPosition  = new Vector3(buildingScript.location.x, buildingScript.location.y, buildingScript.location.z - 10f);
        nextSpawnTime  = Time.time + spawnDelay;

        for (i = 1; i < 11; i++)
        {
            yield return(new WaitForSeconds(1));
        }
        isTraining = false;

        var random1 = Random.Range(0, firstNames.Length);
        var random2 = Random.Range(0, lastNameFirst.Length);
        var random3 = Random.Range(0, lastNameSecond.Length);

        progressIcon              = GameObject.Find("ProgressIcon").GetComponent <Image>();
        workerUC                  = villagerPrefab.GetComponent <UnitController>();
        workerUnitSelection       = villagerPrefab.GetComponent <UnitSelection>();
        progressIcon.sprite       = workerUC.unitIcon;
        workerUC.unitName         = firstNames[random1] + " " + lastNameFirst[random2] + lastNameSecond[random3];
        workerUnitSelection.owner = team;

        Instantiate(villagerPrefab, spawnPosition, Quaternion.identity);
        villagerAudio      = selectedObj.GetComponent <AudioSource>();
        villagerAudio.clip = villagerReporting;
        villagerAudio.Play();
        UI.TownHallSelect();
    }
Exemplo n.º 8
0
    // pass flags -
    public void MakeSelectable(UnitSelection flags)
    {
        bool active          = (flags & UnitSelection.Active) == UnitSelection.Active,
             inactive        = (flags & UnitSelection.Inactive) == UnitSelection.Inactive,
             upgraded        = (flags & UnitSelection.Upgraded) == UnitSelection.Upgraded,
             notUpgraded     = (flags & UnitSelection.NotUpgraded) == UnitSelection.NotUpgraded,
             tempUpgraded    = (flags & UnitSelection.TempUpgraded) == UnitSelection.TempUpgraded,
             notTempUpgraded = (flags & UnitSelection.NotTempUpgraded) == UnitSelection.NotTempUpgraded,
             defending       = (flags & UnitSelection.Defending) == UnitSelection.Defending,
             notDefending    = (flags & UnitSelection.NotDefending) == UnitSelection.NotDefending;

        _units.ForEach(ui => {
            if (inactive && (ui.IsKO || ui.IsDefending || ui.IsPrisoner) ||
                active && (!ui.IsKO && !ui.IsDefending && !ui.IsPrisoner) ||
                upgraded && ui.IsUpgraded ||
                notUpgraded && !ui.IsUpgraded ||
                tempUpgraded && ui.isTempUpgraded ||
                notTempUpgraded && !ui.isTempUpgraded
                )
            {
                ui.EnableSelection();
            }
        });
        _selectMode = true;
    }
Exemplo n.º 9
0
        private void Awake()
        {
            _unitSelection = GetComponentInParent <UnitSelection>(); // TODO: anything better?
            _camera        = Camera.main;
            _rtsControls   = new Rts();

            // Setup UI callbacks, TODO: must check if something cleaner with new input system
            var e = new EventTrigger.Entry {
                eventID = EventTriggerType.BeginDrag
            };

            e.callback.AddListener(StartDraggingAnimal);
            triggerAnimal.triggers.Add(e);
            e = new EventTrigger.Entry {
                eventID = EventTriggerType.EndDrag
            };
            e.callback.AddListener(StopDraggingAnimal);
            triggerAnimal.triggers.Add(e);

            e = new EventTrigger.Entry {
                eventID = EventTriggerType.BeginDrag
            };
            e.callback.AddListener(StartDraggingPlant);
            triggerPlant.triggers.Add(e);
            e = new EventTrigger.Entry {
                eventID = EventTriggerType.EndDrag
            };
            e.callback.AddListener(StopDraggingPlant);
            triggerPlant.triggers.Add(e);

#if UNITY_IOS || UNITY_ANDROID && !UNITY_EDITOR
            UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport.Enable();
#endif
        }
Exemplo n.º 10
0
        //bool displayGUI = false;
        //Progress progressObj;

        private void Awake()
        {
            var playerManager = GameObject.Find("Player Manager");

            selection = playerManager.GetComponent <UnitSelection>();
            manager   = playerManager.GetComponent <GUIManager>();
            gui.type  = "Building";
            if (buildingType == BuildingType.ProgressBuilding)
            {
                InvokeRepeating("Progress", 0, progressRate);
            }
            else if (buildingType == BuildingType.CompleteBuilding)
            {
                gameObject.name = name;
                gui.Awake(gameObject);
                for (int x = 0; x < techEffect.Length; x++)
                {
                    Faction.Tech[techEffect[x].index].AddListener(gameObject);
                    if (Faction.Tech[techEffect[x].index].active)
                    {
                        Upgraded(Faction.Tech[techEffect[x].index].name);
                    }
                }
            }
            grid      = GameObject.Find("UGrid").GetComponent <UGrid>();
            healthObj = GetComponent <Health>();
            //progressObj = GetComponent<Progress>();
        }
Exemplo n.º 11
0
 public void OnPointerExit(PointerEventData eventData)
 {
     if (UnitSelection.Get().GetStart() != this && UnitSelection.Get().GetEnd() != this)
     {
         meshRenderer.material = NormalMaterial;
     }
     name = string.Format("CubeCell({0},{1})", Position.x, Position.y);
 }
Exemplo n.º 12
0
 void OnCollisionEnter(Collision col)
 {
     selectscript = col.gameObject.GetComponent <UnitSelection>();
     if (!collidedObjects.Contains(col.collider) && col.collider.tag == "Selectable" && selectscript.isGathering == true)
     {
         collidedObjects.Add(col.collider);
     }
 }
Exemplo n.º 13
0
 private void SaveSelectedTargetUnit(UnitSelection unitSelection)
 {
     if (savedSelection != null)
     {
         savedSelection.SetSelectionImage(UnitSelection.SelectionType.None);
     }
     savedSelection = unitSelection;
 }
Exemplo n.º 14
0
 /// <summary>
 /// Internal method, do not use.
 /// </summary>
 internal void GatherByWorker(List <UnitController> gatheringUnits)
 {
     if (GameObject == null)
     {
         throw new ResourceExhaustedException(this);
     }
     UnitSelection.SetTarget(gatheringUnits, GameObject, GameObject.transform.position);
 }
Exemplo n.º 15
0
 public void OnPointerEnter(PointerEventData eventData)
 {
     if (UnitSelection.Get().GetStart() != this && UnitSelection.Get().GetEnd() != this)
     {
         meshRenderer.material = HighLightedMaterial;
     }
     AudioManager.Get().PlaySound("Grid/OnMouse", 0.1f);
     name = name + "(OnHovering)";
 }
Exemplo n.º 16
0
    void Start()
    {
        maxHealth = health;

        unitSelection = FindObjectOfType <UnitSelection>();

        agent = gameObject.GetComponent <NavMeshAgent>();
        agent.updateRotation = false;
    }
Exemplo n.º 17
0
 internal static void MoveToPosition(Position where, UnitController unitController)
 {
     UnitSelection.SetTarget(
         new List <UnitController> {
         unitController
     },
         GameManager.Instance.Terrain.gameObject,
         PositionHelper.PositionToLocation(where));
 }
Exemplo n.º 18
0
 public void InitSupportClasses2()
 {
     sight = this.gameObject.AddComponent <UnitSight>();
     // sight.InitSight(this, overlord, assets.sightSphere, sightRadius, mainMap.tileWidth);
     move = this.gameObject.AddComponent <UnitMovement> ();
     //  move.InitMovement(mainMap, assets, baseStats.speed, baseStats.moveCosts, tileLocation);
     selection = this.gameObject.AddComponent <UnitSelection> ();
     //selection.InitSelection (this);
 }
Exemplo n.º 19
0
    public void MakeSelectable(UnitSelection flags)
    {
        Disable();
        getUnitTypeUI(currentPlayer).ForEach(ui => ui.MakeSelectable(flags));
        getUnitTypeUI(currentPlayer).ForEach(ui => ui.Maximise());

        //indicator arrow

        resetSelection();
    }
Exemplo n.º 20
0
    private void Start()
    {
        unitSelection = FindObjectOfType <UnitSelection>();
        handler       = FindObjectOfType <RunHandler>();

        if (unit == handler.curHero)
        {
            unitSelection.CreateDisplay(unit, this.GetComponent <Button>());
        }
    }
Exemplo n.º 21
0
 public void CellSelected(CubeCell cubeCell)
 {
     CurrentSelected = cubeCell;
     //Debug.Log("单元格选中:" + cubeCell.Position.x + "," + cubeCell.Position.y);
     if (cubeCell.CurrentUnit != null)
     {
         return;
     }
     UnitSelection.Get().ClearSelection();
     UIManager.Get().PushPanel(PanelTypes.UnitGenerationPanel);
 }
Exemplo n.º 22
0
 private void Awake()
 {
     place   = gameObject.GetComponent <BuildingPlacement>();
     select  = gameObject.GetComponent <UnitSelection>();
     miniMap = GameObject.Find("MiniMap").GetComponent <MiniMap>();
     faction = GameObject.Find("Faction Manager")
               .GetComponent <FactionManager>()
               .FactionList[select.FactionIndex]
               .GetComponent <Faction>();
     ReconfigureWindows();
 }
Exemplo n.º 23
0
    public void MakeSelectable(UnitSelection flags)
    {
        Disable();
        getUnitTypeUI(currentPlayer).ForEach(ui => ui.MakeSelectable(flags));
        getUnitTypeUI(currentPlayer).ForEach(ui => ui.Maximise());

        //indicator arrow


        resetSelection();
    }
Exemplo n.º 24
0
    private void Awake()
    {
        unitSelection = GetComponent <UnitSelection>();

        if (isRealPlayer && PhotonNetwork.IsConnected)
        {
            photonView.Owner.TagObject = this;
        }
        playerNumber = gameManager.allPlayers.Count;
        gameManager.allPlayers.Add(this);
    }
Exemplo n.º 25
0
 public static void TurnOffUnitSelections(UnitSelection exception)
 {
     foreach (UnitSelection unitSelection in unitSelectionsStatic)
     {
         if (unitSelection != exception)
         {
             unitSelection.frontCard.SetActive(false);
             unitSelection.gameObject.SetActive(false);
         }
     }
 }
Exemplo n.º 26
0
 public void Start(GameObject obj)
 {
     select = GameObject.Find("Player Manager").GetComponent <UnitSelection>();
     if (type == "Unit")
     {
         select.AddUnit(obj);
     }
     else if (type == "Building")
     {
         select.AddBuilding(obj);
     }
 }
Exemplo n.º 27
0
    void Start()
    {
        gameManger    = FindObjectOfType <GameManager> ();
        unitSelection = FindObjectOfType <UnitSelection> ();
        int n = transform.Find("UnitButtons").childCount;

        unitButtons = new GameObject[n];
        for (int i = 0; i < n; i++)
        {
            unitButtons [i] = transform.Find("UnitButtons").GetChild(i).gameObject;
        }
        changeTeamButton = transform.Find("ChangeTeamButton").gameObject;
    }
Exemplo n.º 28
0
 private void Start()
 {
     _unitSelection = GetComponentInParent <UnitSelection>(); // TODO: anything better?
     Gm.instance.MenuStateStarted += () =>
     {
         _unitSelection.disable = true;
     };
     Gm.instance.ExperienceStateStarted += () =>
     {
         _unitSelection.disable = false;
     };
     Gm.instance.PlayStateStarted += () => _unitSelection.disable = false;
 }
Exemplo n.º 29
0
    /// <summary>
    /// State enter event. Initializes state internal variables and prepares view elements.
    /// </summary>
    public override void Enter()
    {
        base.Enter();
        GameManager manager = GameManager.Instance();

        ui = manager.GameUIInstance.HelpUIInstance;
        if (unitSelection == null)
        {
            unitSelection = new UnitSelection(ui.UnitsTabPane);
        }
        InferSelectedItem();
        AttachEventHandlers();
        ui.Show();
    }
Exemplo n.º 30
0
        public static GameObject PlaceProgressBuilding(Building building, List <UnitController> builderUnits,
                                                       int factionIndex, Position position, Quaternion rotation, ResourceManager resourceManager)
        {
            Vector3 location = PositionHelper.PositionToLocation(position);

            try
            {
                BuildingHelper.CheckValidPlacement(building, position, location, false);
            }
            catch (Exception)
            {
                // Visualizing the error placement
                if (GameManager.Instance.Debug)
                {
                    building.ClosePoints(GameManager.Instance.Grid, position.PointLocation);
                }
                throw;
            }
            for (int x = 0; x < building.cost.Length; x++)
            {
                if (building.cost[x] > 0 && resourceManager.resourceTypes[x].amount < building.cost[x])
                {
                    throw new InvalidOperationException(
                              "Not enough resources for placing the " + building + " building");
                }
            }
            for (int x = 0; x < building.cost.Length; x++)
            {
                if (building.cost[x] > 0)
                {
                    resourceManager.resourceTypes[x].amount -= building.cost[x];
                }
            }
            GameObject buildingObject;

            if (building.autoBuild)
            {
                buildingObject = BuildingHelper.InstantiateProgressBuilding(
                    building, building.obj, factionIndex, position, rotation)
                                 .gameObject;
            }
            else
            {
                buildingObject = BuildingHelper.InstantiateProgressBuilding(
                    building, building.progressObj, factionIndex, position, rotation)
                                 .gameObject;
                UnitSelection.SetTarget(builderUnits, buildingObject, buildingObject.transform.position);
            }
            return(buildingObject);
        }
 /// <summary>
 /// Clears attack panels and corresponding buttons.
 /// </summary>
 private void ClearAttackPanels()
 {
     UnitSelection.DetectTarget();
     UnitSelection.detectedEnemy = null;
     if (UnitSelection.enemySelector != null)
     {
         UnitSelection.enemySelector.SetActive(false);
     }
     foreach (GameObject actionBtn in actionButtons)
     {
         Destroy(actionBtn);
     }
     actionButtons.Clear();
 }
Exemplo n.º 32
0
 void Start()
 {
     unit                 = GetComponent <Unit>();
     unitSelection        = FindObjectOfType <UnitSelection>();
     canvas               = unitSelection.hudCanvas.transform;
     healthBar            = Instantiate(healthBarPrefab).GetComponent <HealthBar> ();
     healthBar.canvasRect = canvas.GetComponent <RectTransform>();
     healthBar.transform.SetParent(canvas);
     healthBar.maxHealth = maxHealth;
     healthBar.entity    = healthBarPosition;
     healthBar.gameObject.SetActive(unit.isSelected);
     health  = maxHealth;
     isAlive = true;
 }
Exemplo n.º 33
0
 public CirclePattern(Point location, UnitSelection selection, int radius, int rotation)
     : base(location, selection)
 {
     this.radius = radius;
     this.rotation = rotation;
 }
    // Use this for initialization
    void Start()
    {
        selection = GameObject.Find("Player Manager").GetComponent<UnitSelection>();
        manager = GameObject.Find("Player Manager").GetComponent<GUIManager>();
        gui.type = "Building";
        g = GameObject.Find("Player Manager").GetComponent<GUIManager>().group;
        if(buildingType == BuildingType.ProgressBuilding){
            InvokeRepeating("Progress", 0, progressRate);
        }

        else if(buildingType == BuildingType.CompleteBuilding){
            gameObject.name = name;
            gui.Start(gameObject);
            for(int x = 0; x < techEffect.Length; x++){
                g.tech[techEffect[x].index].AddListener(gameObject);
                if(g.tech[techEffect[x].index].active){
                    Upgraded(g.tech[techEffect[x].index].name);
                }
            }
        }
        grid = GameObject.Find("UGrid").GetComponent<UGrid>();
        healthObj = GetComponent<Health>();
        progressObj = GetComponent<Progress>();
    }
Exemplo n.º 35
0
 public void ShowUnitSelectionUI(UnitSelection flags)
 {
     _ArmyUI.Show();
     _ArmyUI.MakeSelectable(flags);
     Disable();
 }
 public void Start()
 {
     if(resourceManager == null){
         resourceManager = gameObject.GetComponent<ResourceManager>();
     }
     if(fog == null){
         GameObject nObj;
         nObj = GameObject.Find("Fog");
         if(nObj)
             fog = nObj.GetComponent<Fog>();
     }
     if(unitSelect == null){
         unitSelect = gameObject.GetComponent<UnitSelection>();
     }
     if(grid == null){
         GameObject nObj;
         nObj = GameObject.Find("UGrid");
         if(nObj)
             grid = nObj.GetComponent<UGrid>();
     }
 }
Exemplo n.º 37
0
 public UnitGroupPattern(Point location, UnitSelection selection)
 {
     this.location = location;
     this.selection = selection;
 }
Exemplo n.º 38
0
 void Start()
 {
     if(place == null){
         place = gameObject.GetComponent<BuildingPlacement>();
     }
     if(select == null){
         select = gameObject.GetComponent<UnitSelection>();
     }
     if(resourceManager == null){
         resourceManager = gameObject.GetComponent<ResourceManager>();
     }
     ReconfigureWindows();
 }
Exemplo n.º 39
0
 public void Start(GameObject obj)
 {
     select = GameObject.Find("Player Manager").GetComponent<UnitSelection>();
     if(type == "Unit"){
         select.AddUnit(obj);
     }
     else if(type == "Building"){
         select.AddBuilding(obj);
     }
 }
 void Start()
 {
     selection = GameObject.Find("Player Manager").GetComponent<UnitSelection>();
     vision = gameObject.GetComponent<VisionSignal>();
     miniMap = gameObject.GetComponent<MiniMapSignal>();
     gui.type = "Unit";
     mGroup = GameObject.Find("Faction Manager").GetComponent<GroupManager>().groupList[group].GetComponent<Group>();
     gui.Start(gameObject);
     for(int x = 0; x < techEffect.Length; x++){
         mGroup.tech[techEffect[x].index].AddListener(gameObject);
         if(mGroup.tech[techEffect[x].index].active){
             Upgraded(mGroup.tech[techEffect[x].index].name);
         }
     }
     gameObject.name = name;
     healthObj = GetComponent<Health>();
 }