Наследование: BasicController
 public Entity ReplaceUnitView(UnitController newView) {
     var componentPool = GetComponentPool(UnitsComponentIds.UnitView);
     var component = (UnitViewComponent)(componentPool.Count > 0 ? componentPool.Pop() : new UnitViewComponent());
     component.View = newView;
     ReplaceComponent(UnitsComponentIds.UnitView, component);
     return this;
 }
Пример #2
0
 // Use this for initialization
 void Awake()
 {
     _unitCtrl = GetComponent <UnitController>();
     _unitMove = GetComponent<UnitMove>();
     _unitAttack = GetComponent<UnitAttack>();
     _unitSpine = GetComponentInChildren<UnitSpine>() ? GetComponentInChildren<UnitSpine>() : null;
 }
Пример #3
0
 void Start()
 {
     if (controller == null) {
         controller = EmptyUnitController.instance;
     }
     new ValueTracker<UnitController>(v => controller = v, () => controller);
 }
    // Use this for initialization
    void Start()
    {
        unit = gameObject.GetComponentInParent<UnitController>();



    }
Пример #5
0
    // Use this for initialization
    void Start () {
        unit = gameObject.GetComponentInParent<UnitController>();
        ps = transform.Find("Particle System").GetComponent<ParticleSystem>();
        ps.enableEmission = false;
        noFire();


    }
        public static void Main()
        {
            IFactory factory = new SimpleFactory();
            var controller = new UnitController(factory);
            IStudent student = controller.GetAllStudents(new []{"Online", "Iskra Radeva", "5.0 6 6"});

            Console.WriteLine($"Name {student.Name}");      
        }
Пример #7
0
 void Start()
 {
     unit = GetComponent<UnitController>();
     if(unit == null){
         state = 1;
         build = GetComponent<BuildingController>();
     }
 }
Пример #8
0
 void Attack(UnitController attacked)
 {
     GameObject g = Instantiate(bulletPrefab, transform.position + Vector3.up * 3, Quaternion.identity) as GameObject;
     //GameObject g = (GameObject)Instantiate(bulletPrefab, transform.position, Quaternion.identity);
     g.GetComponent<Bullet> ().damage = Damage;
     g.GetComponent<Bullet>().target = attacked.transform;
     g.GetComponent<Bullet> ().origin = gameObject;
 }
Пример #9
0
 void Awake()
 {
     mapCtrl = GetComponent<MapController>();
     wispCtrl = GetComponent<WispController>();
     unitCtrl = GetComponent<UnitController>();
     camCtrl = GetComponent<CameraController>();
     gameUICtrl = GetComponent<GameUIController>();
     spLib = GetComponent<SpriteLibrary>();
 }
Пример #10
0
 void OnTriggerEnter(Collider coll)
 {
     if (coll.gameObject.CompareTag("Unit")) {
         script = coll.gameObject.GetComponent<UnitController>();
         int state = cont.DetermineRelations(script.group);
         if(state == 2){
             cont.SphereSignal(type, coll.gameObject);
         }
     }
 }
Пример #11
0
 private IEnumerator checkTarget()
 {
     while(true)
     {
         if (_target == null)
         {
             _target = findTargetUnit();
         }
         yield return new WaitForSeconds(0.1f);
     }
 }
Пример #12
0
 public void AddMate(UnitController newGuy)
 {
     if(this.characterCount<this.teamSize)
     {
         this.mates [characterCount] = newGuy;
         this.mates [characterCount].transform.rotation = face;
         this.mates [characterCount].id = characterCount;
         this.mates [characterCount].SetColor (teamColor);
         this.characterCount++;
     }
 }
Пример #13
0
 public UnitFSM(UnitController controller) {
     StateIdle idleState = new StateIdle(controller);
     AddState(idleState);
     AddState(new StateMove(controller));
     AddState(new StateAttack(controller));
     AddState(new StateAttackMove(controller));
     AddState(new StateChase(controller));
     AddState(new StateHoldPosition(controller));
     defaultState = idleState;
     Reset();
 }
Пример #14
0
    // Use this for initialization
    void Start()
    {
        unitController = GetComponent<UnitController> ();

        rotateRightKeyCode = (KeyCode) System.Enum.Parse(typeof(KeyCode), RotateRightKey);
        rotateLeftKeyCode = (KeyCode) System.Enum.Parse(typeof(KeyCode), RotateLeftKey);

        rotateRight += RotateRight;
        rotateLeft += RotateLeft;

        placeBomb += PlaceBomb;
    }
Пример #15
0
 void Start()
 {
     m_tController = gameObject.GetComponentInParent<UnitController>();
     m_tBody = gameObject.GetComponentInParent<BodyController>();
     Renderer[] tFireEffects = gameObject.GetComponentsInChildren<Renderer>();
     foreach (Renderer tEffect in tFireEffects) {
         if (tEffect.name == "Fire 1")
             m_tFireEffect1 = tEffect;
         else if (tEffect.name == "Fire 2")
             m_tFireEffect2 = tEffect;
     }
 }
Пример #16
0
 private void AttackUnitWithDelay(UnitController unit, int hp)
 {
     if (currentDelay < DelayTime)
     {
         currentDelay += Time.deltaTime;
     }
     else
     {
         AttackUnit(unit, hp);
         Debug.Log("Give attack !");
         currentDelay = 0;
     }
 }
Пример #17
0
    protected override void OnOwnerFound()
    {
        base.OnOwnerFound();
        if (dropped)
        {
            return;
        }
        unitController   = curUnitOwner.GetComponent <UnitController>();
        playerController = unitController as PlayerController;
        muzzle           = transform.FindDeepChild(Data.muzzlePos);
        muzzle.forward   = unitController.transform.forward;

        if (UIPlayer.instance && Data.aimFX)
        {
            UIPlayer.instance.AddAimFXHandler(Data.aimFX);
        }
    }
Пример #18
0
    public override bool CheckCondition(UnitController controller)
    {
        NavMeshHit hit;

        Vector3 target = controller.Unit.transform.forward + controller.Unit.transform.position;

        if (NavMesh.SamplePosition(target, out hit, 0.1f, NavMesh.AllAreas))
        {
            // Can move forward
            return(false);
        }
        else
        {
            // Can't move forward
            return(true);
        }
    }
Пример #19
0
    private void Awake()
    {
        UnitController unit = GetComponent <UnitController>();

        if (unit != null)
        {
            pathColor = unit.color;
        }

        grid        = FindObjectOfType <Grid>();
        destination = transform.position;

        if (selectedRenderer != null)
        {
            selectedRenderer.material.color = pathColor;
        }
    }
Пример #20
0
        public void Init()
        {
            var unit = new List <Unit>()
            {
                new Unit {
                    UnitID = 1, Name = "Kilo"
                },
                new Unit {
                    UnitID = 2, Name = "Bag"
                }
            };
            var unitService = new Mock <IUnitService>();

            unitService.Setup(m => m.GetAllUnit()).Returns(unit);

            _unitController = new UnitController(unitService.Object);
        }
Пример #21
0
 /// <summary>
 /// Internal method, do not use.
 /// </summary>
 internal bool FinishBuildingByWorker(UnitController builderUnit)
 {
     if (Destroyed)
     {
         return(false);
     }
     if (GameManager.Instance.Factions[BuildingController.FactionIndex]
         .Relations[builderUnit.FactionIndex]
         .state == 2)
     {
         throw new Exception("The target Building belongs to an enemy, so a worker cannot be construct it");
     }
     UnitSelection.SetTarget(new List <UnitController> {
         builderUnit
     }, GameObject, GameObject.transform.position);
     return(true);
 }
Пример #22
0
    public void CmdReleaseUnit(GameObject unit)
    {
        UnitController unitController = unit.GetComponent <UnitController>();

        unitController.SetCheckpointState(UnitController.EUnitCheckpointState.bannedFromStock);
        unit.SetActive(true);
        unitController.RpcSetActive(true);
        unit.transform.SetParent(m_friendsUnits.transform);
        unitController.SetObjective(Vector3.zero);
        ChangeNbUnitsStocked(false, unit);
        unitController.RpcDecrementTerritotyUnitNumberOnRelease(); //needed to cancel territory OnTriggerEnter, when unit is enable.

        if (m_enemiesUnits.transform.childCount == 0)
        {
            PopulateStockUnits();
        }
    }
Пример #23
0
 /// <summary>
 /// Internal method, do not use.
 /// </summary>
 internal bool AttackedByUnit(UnitController attackerUnit)
 {
     if (Destroyed)
     {
         return(true);
     }
     if (GameManager.Instance.Factions[BuildingController.FactionIndex]
         .Relations[attackerUnit.FactionIndex]
         .state != 2)
     {
         throw new Exception("The target Building is not enemy, so it cannot be attacked");
     }
     UnitSelection.SetTarget(new List <UnitController> {
         attackerUnit
     }, GameObject, GameObject.transform.position);
     return(false);
 }
Пример #24
0
        public void ReleaseUnit(UnitController unitController)
        {
            if (unitController.Character == null)
            {
                return;
            }

            GameObjectPool <UnitController> unitPool;

            if (!pools.TryGetValue(unitController.Character.UnitType, out unitPool))
            {
                Debug.LogError(string.Format("Can't find pool for {0}", unitController.Character.UnitType));
                return;
            }
            unitController.Clear();
            unitPool.ReleaseObject(unitController);
        }
Пример #25
0
    public override void OnCrossNode(Node n)
    {
        List <Node> nodes = n.GetAllNodes();

        if (nodes.Count > 1)
        {
            //print(n.name);
            SetTargetNode(nodes[0]);
            for (int i = 1; i < nodes.Count; i++)
            {
                GameObject     go = Instantiate(gameObject, transform.position, Quaternion.identity, transform.parent);
                UnitController uc = go.GetComponent <UnitController>();
                uc.SetTargetNode(nodes[i]);
                GameManager.instance.OnUnitCreated(uc);
            }
        }
    }
Пример #26
0
 //Filter unit timetable by campus
 private void CampusSorter_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (UnitClassTimes != null)
     {
         UnitController UnitBoss = (UnitController)Application.Current.FindResource("UnitBoss");
         if (UnitClassTimes.Count != 0)
         {
             UnitClassGrid.Items.Clear();
             Campus           cam = (Campus)e.AddedItems[0];
             List <UnitClass> SortedUnitClassTimes = UnitBoss.Filter(cam, UnitClassTimes);
             foreach (UnitClass Classes in SortedUnitClassTimes)
             {
                 UnitClassGrid.Items.Add(Classes);
             }
         }
     }
 }
Пример #27
0
    public override void OnControllerChanged(UnitController unitController)
    {
        UnitControllerType type = unitController.GetUnitControllerType();

        switch (type)
        {
        case UnitControllerType.PLAYER_CONTROLLER: {
            Debug.Log("Unit " + GetHashCode() + " Is Now Controlled By Player Controller");
        }
        break;

        case UnitControllerType.AI_CONTROLLER: {
            Debug.Log("Unit " + GetHashCode() + " Is Now Controlled By AI Controller");
        }
        break;
        }
    }
Пример #28
0
    private bool NextUnit()
    {
        List <UnitController> maxInitiativeUnits = new List <UnitController>();
        int maxInitiative = int.MinValue;

        //bool player = false, enemy = false;

        foreach (UnitController unit in BattlefieldUnits.Units)
        {
            if (unit.HasPlayed)
            {
                continue;
            }
            if (maxInitiative == unit.Initiative)
            {
                maxInitiativeUnits.Add(unit);
                //if (unit.PlayersArmy) player = true;
                //else enemy = true;
            }
            else if (maxInitiative < unit.Initiative)
            {
                maxInitiative = unit.Initiative;
                //player = unit.PlayersArmy;
                //enemy = !unit.PlayersArmy;
                maxInitiativeUnits = new List <UnitController> {
                    unit
                };
            }
        }

        /*if (player && enemy)
         * {
         *      List<Unit> newMaxInitiativeUnits = new List<Unit>();
         *      newMaxInitiativeUnits.AddRange(RandomUtil.RandomEvent(0.5)
         *              ? maxInitiativeUnits.Where(unit => unit.PlayersArmy)
         *              : maxInitiativeUnits.Where(unit => !unit.PlayersArmy));
         *      maxInitiativeUnits = newMaxInitiativeUnits;
         * }*/

        if (maxInitiativeUnits.Count == 0)
        {
            return(false);
        }
        ActiveUnit = RandomUtil.RandomElement(maxInitiativeUnits);
        return(true);
    }
Пример #29
0
 void Update()
 {
     if (Fountain != null)
     {
         if (Fountain.UnitsIsReadyCount >= 1)
         {
             Fountain.UnitsIsReadyCount -= 1;
             Vector3 position =
                 new Vector3(transform.position.x, transform.position.y, transform.position.z + transform.localScale.z);
             UnitController mainCharacterController = (UnitController)Instantiate(MainCharacterController, position, Quaternion.identity);
             mainCharacterController.Unit = Fountain.Spam();
             mainCharacterController.gameObject.transform.SetParent(transform);
             //unitController.Target = WayPoint;//.transform;
             MainCharacterController = mainCharacterController;
         }
     }
 }
    /// <summary>
    /// Find the friendly unit nearest to a given enemy unit
    /// </summary>
    /// <param name="enemyUnitController">unitcontroller of enemy unit</param>
    /// <returns>unitcontroller of nearest friendly unit</returns>
    private UnitController FindNearestFriendlyUnit(UnitController enemyUnitController)
    {
        //loop over each friendly unit and check for the shortest distance

        int            shortestDistance = Int32.MaxValue;     //distance to unit with shortest distance
        UnitController shortestDistanceUnitController = null; //unitcontroller of unit with shortest distance

        foreach (var friendlyUnitController in playerArmy)
        {
            Coords friendlyUnitCoords = friendlyUnitController.GetUnitCoords();

            if (enemyUnitController.CanAttack(friendlyUnitCoords))
            {
                //if enemy unit can attack friendly, return the attackable unit
                return(friendlyUnitController);
            }

            foreach (var direction in DirectionMethods.GetClockwise())
            {
                BFS    bfs           = new BFS();
                Coords coordsToCheck = friendlyUnitCoords.Get(direction); //coords right next to unit in direction

                //check if enemy unit has path to friendly unit
                if (enemyUnitController.HasPath(coordsToCheck, ref bfs))
                {
                    //get length of solution and check if shorter than the previous shortest distance
                    int solutionLength = bfs.GetSolutionLength();
                    if (solutionLength < shortestDistance)
                    {
                        shortestDistance = solutionLength;
                        shortestDistanceUnitController = friendlyUnitController;
                    }
                }
            }
        }

        if (shortestDistanceUnitController == null)
        {
            //there is no path to any friendly unit
            //just select the first enemy
            shortestDistanceUnitController = playerArmy[0];
        }

        return(shortestDistanceUnitController);
    }
Пример #31
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Vector3 mousePos = Input.mousePosition;
         mousePos.z = 10;
         Vector3      worldPos = Camera.main.ScreenToWorldPoint(mousePos);
         RaycastHit2D hit      = Physics2D.Raycast(worldPos, Vector2.zero);
         if (!hit)
         {
             return;
         }
         if (hit.collider.CompareTag("Human"))
         {
             UnitController footman =
                 hit.collider.gameObject.GetComponent <UnitController>();
             if (footman == null)
             {
                 return;
             }
             if (!Input.GetKey(KeyCode.LeftControl))
             {
                 footmen.Clear();
             }
             if (footmen.IndexOf(footman) < 0)
             {
                 footmen.Add(footman);
                 footman.selected = true;
                 GetComponent <AudioSource>().Play();
             }
         }
         else if (hit.collider.CompareTag("Orc"))
         {
             Attack(hit.collider.gameObject);
         }
         else if (hit.collider.CompareTag("Tile"))
         {
             MoveSelection(worldPos);
         }
     }
     if (Input.GetMouseButtonDown(1))
     {
         footmen.Clear();
     }
 }
Пример #32
0
 protected override void OnTriggerStay2D(Collider2D collision)
 {
     if (!collision.tag.Equals("Terrain"))
     {
         UnitController u = collision.transform.root.GetComponent <UnitController>();
         if (u.unitType != unitType && canDetect)
         {
             if (!hitList.Contains(u.gameObject) && !exclusiveTarget)
             {
                 onHit(u.gameObject);
             }
             else if (!hitList.Contains(u.gameObject) && u.gameObject.Equals(Target))
             {
                 onHit(u.gameObject);
             }
         }
     }
 }
Пример #33
0
 internal override bool Progress(IUnit unit, UnitController unitController)
 {
     if (!base.Progress(unit, unitController))
     {
         return(false);
     }
     // If the Action was already running and any target wasn't followed, it has ended
     if (unitController.IsAttackMove && unitController.AttackMoveTarget == null)
     {
         unitController.IsAttackMove = false;
         return(true);
     }
     // Starts the movement towards the goal
     Move.MoveToPosition(Where, unitController);
     unitController.IsAttackMove     = true;
     unitController.AttackMoveTarget = null;
     return(false);
 }
Пример #34
0
        public override void OnStart(GameObject go)
        {
            UnitController componentInParent = (UnitController)go.GetComponentInParent <UnitController>();

            if (!Object.op_Implicit((Object)componentInParent))
            {
                return;
            }
            if (!this.IsNoResetPrimaryHand)
            {
                componentInParent.ResetAttachmentLists(UnitController.EquipmentType.PRIMARY);
            }
            if (this.IsNoResetSecondaryHand)
            {
                return;
            }
            componentInParent.ResetAttachmentLists(UnitController.EquipmentType.SECONDARY);
        }
Пример #35
0
    private void DoDamageToForests(UnitController controller)
    {
        Vector3 target = controller.Unit.transform.forward + controller.Unit.transform.position;

        RaycastHit[] hits = Physics.RaycastAll(target + Vector3.up * 5f, Vector3.down, 10f);
        foreach (RaycastHit hit in hits)
        {
            OneHitDestructible ohd = hit.collider.gameObject.GetComponentInChildren <OneHitDestructible>();
            if (ohd != null)
            {
                while (ohd != null)
                {
                    ohd.TakeDamage(1, Damageable.DamageTypes.ElephantCharge);
                    ohd = hit.collider.gameObject.GetComponentInChildren <OneHitDestructible>();
                }
            }
        }
    }
Пример #36
0
 void Scan()
 {
     shipTargets.Clear();
     Collider[] possibleTargets = Physics.OverlapSphere(transform.position, radarRange, layer);
     foreach (Collider c in possibleTargets)
     {
         UnitController uc = c.GetComponent <UnitController>();
         if (uc)
         {
             if (uc.team != team)
             {
                 shipTargets.Add(uc);
             }
         }
     }
     //call method in fcs
     fcs.UpdateShipTargetList(shipTargets);
 }
Пример #37
0
    public virtual void AddUnit(UnitController unit, bool addAtRandom = false)
    {
        if (PlayerInfo.Units.Contains(unit))
        {
            return;
        }

        if (addAtRandom)
        {
            var r     = new System.Random();
            int index = r.Next(PlayerInfo.Units.Count());
            PlayerInfo.Units.Insert(index, unit);
        }
        else
        {
            PlayerInfo.Units.Add(unit);
        }
    }
Пример #38
0
    private void CreateUnit(Constant.SpawnTypeUnit spawnType)
    {
        GameObject go = Instantiate(GameManager.Instance.GetUnitForPlayer(spawnType, m_playerNumber), m_door.position, m_door.rotation);

        NetworkServer.Spawn(go);
        GameManager.Instance.GetPlayer(m_playerNumber).IncrementNbUnitInGame();
        RpcPlaySpawnFX();
        UnitController goUnitController = go.GetComponent <UnitController>();

        goUnitController.SetObjective(m_target.transform.position);
        goUnitController.SetPlayerNumber(m_playerNumber);
        goUnitController.SetParentPath(m_path);
        goUnitController.SetNexusEnemy(m_target.transform.position);
        if (m_playerNumber != PlayerEntity.Player.Bot)
        {
            TargetSoundEmitter(GameManager.Instance.GetPlayer(m_playerNumber).connectionToClient);
        }
    }
Пример #39
0
        public override void OnStart(GameObject go)
        {
            UnitController componentInParent = (UnitController)go.GetComponentInParent <UnitController>();

            if (!Object.op_Implicit((Object)componentInParent))
            {
                return;
            }
            if (this.SwitchPrimaryHand != SwitchEquipment.eSwitchTarget.NO_CHANGE)
            {
                componentInParent.SwitchEquipmentLists(UnitController.EquipmentType.PRIMARY, (int)this.SwitchPrimaryHand);
            }
            if (this.SwitchSecondaryHand == SwitchEquipment.eSwitchTarget.NO_CHANGE)
            {
                return;
            }
            componentInParent.SwitchEquipmentLists(UnitController.EquipmentType.SECONDARY, (int)this.SwitchSecondaryHand);
        }
Пример #40
0
    void SelectTile()
    {
        if (currentTile)
        {
            currentTile.SetDefault();
        }

        currentTile = GridManager.instance.GetGridAtMouse();

        if (currentTile)
        {
            currentTile.SetGreen();
            if (currentTile.unit)
            {
                selectedUnit = currentTile.unit;
            }
        }
    }
Пример #41
0
        public override void ApplyEffect(GameManager gm, UnitController user, UnitController guyHit, Vector3Int targetLocation)
        {
            if (guyToSummon == null)
            {
                Debug.LogError("Never got set up to summon unit");
                return;
            }

            if (guyHit != null)
            {
                //someone in the way
                guyHit.TakeDamage(1, Effect.DamageTypes.SummoningBlocked);
            }
            else
            {
                gm.SpawnUnit(targetLocation, guyToSummon.LoadoutName, side, guyToSummon);
            }
        }
Пример #42
0
    /// <summary>
    /// Find unit on board by coordinates list
    /// </summary>
    /// <returns>Controller</returns>
    private UnitController FindUnit(Team team)
    {
        UnitController unit = null;

        for (int i = 0; i < _list.Count; i++)
        {
            unit = _manager.GetUnitOnPosition(_list[i]);
            if (unit != null && unit.TeamId != team && unit.Status != UnitStatus.DEAD)
            {
                return(unit);
            }
            else
            {
                unit = null;
            }
        }
        return(unit);
    }
Пример #43
0
    public float GetAIAttackTimer()
    {
        float timer = UnityEngine.Random.Range(StartingMinimumTimer, StartingMaximmTimer);

        timer -= (int)Difficulty * DifficultyTimeDeduction;

        timer -= numConvergences * ConvergenceTimeDeduction;

        timer += (UnitController.GetUnitCountForFaction(FactionController.OtherFaction1) - UnitController.GetUnitCountForFaction(FactionController.PlayerFaction)) * UnitDifferenceTime;

        timer += (AIGameStateInfo.numTowers - playerGameStateInfo.numTowers) * TowerDifferencTime;

        timer += (AIGameStateInfo.numUpgrades - playerGameStateInfo.numUpgrades) * UpgradeDifferenceTime;

        timer = Mathf.Clamp(timer, AbsoluteMinimumTimer, AbsoluteMaximumTimer);

        return(timer);
    }
Пример #44
0
    private void Awake()
    {
        unitController = FindObjectOfType <UnitController>();

        BaseController[] controllers = FindObjectsOfType <BaseController>();

        foreach (BaseController controller in controllers)
        {
            if (controller.TeamID == GameWorld.Instance.LocalTeamId)
            {
                baseController = controller;
                baseController.OnToolChanged += OnToolChanged;
                baseController.GetGameResources().OnResourceAmountChanged += delegate { UpdateResourceTextObject(); };
                UpdateResourceTextObject();
                break;
            }
        }
    }
Пример #45
0
    private void RemoveSelection(UnitController target, bool removeFromList = true)
    {
        bool selectedIndex = this.selectedUnits.Contains(target);

        if (selectedIndex)
        {
            //target.GetComponent<Outline>().OutlineWidth = 0.0f;
            Selectable selected = target.GetComponent <Selectable> ();
            if (selected.selectionCircle.activeSelf)
            {
                selected.selectionCircle.SetActive(false);
            }
            if (removeFromList)
            {
                this.selectedUnits.Remove(target);
            }
        }
    }
Пример #46
0
    private void RespawnUnderPlayerControl(PlayerEntity.Player killer)
    {
        for (int i = 0; i < m_nbGolemsToSpawn; i++)
        {
            GameObject theSpawnPoint     = m_golemsSpawnPoints[i].gameObject;
            GameObject prefabGolemPlayer = m_golemsList[i].GetComponent <GolemNeutralUnit>().GetPrefabGolemPlayer(killer);
            GameObject theGolem          = Instantiate(prefabGolemPlayer, theSpawnPoint.transform.position, theSpawnPoint.transform.rotation);

            Nexus ennemyNexus = GetNearestEnemyNexus(killer);

            UnitController golemUnitController = theGolem.GetComponent <UnitController>();
            golemUnitController.SetObjective(ennemyNexus.transform.position);
            golemUnitController.SetPlayerNumber(killer);
            golemUnitController.SetNexusEnemy(ennemyNexus.transform.position);
            NetworkServer.Spawn(theGolem);
        }
        RpcRespawnGolemFX(killer);
    }
Пример #47
0
 // Update is called once per frame
 void Update()
 {
     if (first)
     {
         gui = GameObject.FindGameObjectWithTag("GUI").GetComponent<GUIclass>();
         unit = this.transform.parent.gameObject;
         unitController = unit.GetComponent<UnitController>();
         first = false;
     }
     isCommanded = gui.isCommandModeON;
     if (!isCommanded)
     {
         if (enemies.Count > 0)
         {
             if (unitController.getTarget() == null)
             {
                 unitController.setTarget(enemies.First());
             }
         }
     }
 }
Пример #48
0
    public void CreateDot(UnitController unit)
    {
        float terrainWidth = MissionTerrain.terrainData.size.x;
        float terrainHeight = MissionTerrain.terrainData.size.z;

        // Represents the unit by a dot :
        GameObject unitDot = new GameObject("UnitDot");
        RawImage dot = unitDot.gameObject.AddComponent<RawImage>();

        Texture2D tex = new Texture2D(4, 4);
        Color fillColor = new Color(1f, 0.0f, 0.0f);
        var fillColorArray = tex.GetPixels();
        for (var i = 0; i < fillColorArray.Length; ++i)
        {
            fillColorArray[i] = fillColor;
        }

        tex.SetPixels(fillColorArray);

        tex.Apply();

        dot.transform.SetParent(Minimap.transform);

        dot.texture = tex;
        dot.rectTransform.anchorMax = new Vector2(0, 1);
        dot.rectTransform.anchorMin = new Vector2(0, 1);
        dot.rectTransform.pivot = new Vector2(0.5f, 0.5f);
        dot.rectTransform.sizeDelta = new Vector2(4, 4);

        float MinimapWidth = Minimap.GetComponent<RectTransform>().rect.size.x;
        float MinimapHeight = Minimap.GetComponent<RectTransform>().rect.size.y;
        dot.rectTransform.anchoredPosition = new Vector2(unit.transform.position.x / terrainWidth * MinimapWidth, unit.transform.position.z / terrainWidth * MinimapHeight - MinimapHeight);
        //dot.texture = Resources.Load ("dot.png") as Texture2D;

        // Assign this dot to an unit.
        unit.AssiociatedDot = dot;
    }
Пример #49
0
 private void HealUnit(UnitController unit, int hp)
 {
     unit.Heal(hp);
 }
Пример #50
0
 public StateChase(UnitController controller) : base(FSMStates.Chase, controller) { }
Пример #51
0
 // Use this for initialization
 void Start()
 {
     _unitController = transform.parent.GetComponent<UnitController>();
 }
Пример #52
0
 public static UnitController Fixture()
 {
     UnitController controller = new UnitController(new UnitRepository(), "", new LoginView());
     return controller;
 }
Пример #53
0
 public void CancelConstruction()
 {
     isSettingConstructionPoint = false;
     Destroy(constructionSite.gameObject);
     constructionSite = null;
     constructor = null;
 }
Пример #54
0
 public StateAttack(UnitController controller) : base(FSMStates.Attack, controller) { }
Пример #55
0
 public void addWatchUnit(UnitController uc)
 {
     m_watchList.Add(uc);
 }
Пример #56
0
    public void SpawnStructure(string structureName, Vector3 buildPoint, UnitController builder, Rect playingArea)
    {
        GameObject structureToSpawn = (GameObject)Instantiate(GameManager.activeInstance.GetStructurePrefab(structureName),
            buildPoint, new Quaternion());

        constructionSite = structureToSpawn.GetComponent<StructureController>();
        if (constructionSite != null)
        {
            constructor = builder;
            isSettingConstructionPoint = true;
            constructionSite.SetTransparencyMaterial(notAllowedMaterial, true);
            constructionSite.SetColliders(false);
            constructionSite.playingArea = playingArea;
        }
        else
        {
            Destroy(structureToSpawn);
        }
    }
Пример #57
0
 public StateMove(UnitController controller) : base(FSMStates.Move, controller) { }
Пример #58
0
 public void RemovePlayerActions(UnitController unit)
 {
     //PlayerAction[] acts = new PlayerAction[MaxActions];
     PlayerAction temp;
     byte count=0;
     for(int i = 0; i<CurrentActionSet.Length;i++)
     {
         if(CurrentActionSet[i]!= null && CurrentActionSet[i].iCh==unit)
         {
             count++;
             temp = CurrentActionSet[MaxActions-1];
             //CurrentActionSet[MaxActions-1] = CurrentActionSet[i];
             CurrentActionSet[i] = temp;
         }
     }
     //		for(int c = count; c>0;c--)
     //		{
     //			CurrentActionSet[CurrentActionSet.Length-c] = null;
     //		}
     actionCount[CurrentTeamNum] -= count;
 }
Пример #59
0
 private void AttackUnit(UnitController unit, int hp)
 {
     unit.Damage(hp);
 }
 public StateHoldPosition(UnitController controller, GameplayManager gm)
     : base(FSMStates.HoldPosition, controller, gm)
 {
 }