示例#1
0
    public void UpdateCard(GameUnit focusUnit, bool showExtras)
    {
        ClearCard();

        this.focusUnit = focusUnit;

        statsCanvasGroup.alpha = 1;

        if (focusUnit.unitType == UnitType.Character)
        {
            GameCharacter focusCharacter = (GameCharacter)focusUnit;
            UpdatePortrait(focusCharacter.avatarRenderer.sprite);
            UpdateStats(focusCharacter.move.adjustedMoveRange, focusCharacter.maxSize);
            UpdateSpells(focusCharacter.spellBox.spells);
            if (showExtras)
            {
                UpdateCharacterExtras();
            }
        }
        else
        {
            UpdatePortrait(focusUnit.GetComponent <SpriteRenderer>().sprite);
        }

        UpdateHeader(focusUnit.gameName, focusUnit.gameDescription);
    }
示例#2
0
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        // Unit placing logic
        GameUnit placeableUnit = inputController.GetPlaceableUnit();

        if (placeableUnit != null)
        {
            FieldCell cell;
            if (placeableUnit.cost <= resources.GetMeal() &&
                (cell = inputController.GetHoveredCell()) != null)
            {
                cell.Highlight();

                if (inputController.AcceptButtonPressed())
                {
                    if (placeableUnit.tag == "Building")
                    {
                        CmdPlaceBuilding(cell.gameObject, placeableUnit.GetComponent <NetworkIdentity>().assetId);
                    }
                    else if (placeableUnit.tag == "Pawn")
                    {
                    }
                }
            }
        }

        // Selecting units logic
        if (inputController.SelectButtonPressed())
        {
            GameUnit unit = inputController.GetHoveredUnit();
            if (unit != null)
            {
                inputController.SelectUnit(unit);
            }
        }

        // Deselecting buildings logic
        if (inputController.RejectButtonPressed())
        {
            inputController.SelectPlaceableUnit(null);
        }

        // Exit logic
        if (inputController.ExitButtonPressed())
        {
            StopNetworkManager();
        }

        // Update input controller
        if (isLocalPlayer && resources != null)
        {
            inputController.SetMealAmount(resources.GetMeal());
            inputController.SetManaAmount(resources.GetMana());
        }
    }
示例#3
0
    //To use OnTrigger...() methods, you need to attach this script with a game object that have a Collider and a RigidBody.
    //And remember to untick (uncheck) the "Use Gravity" in RigidBody.
    public void OnTriggerEnter(Collider other)
    {
        GameUnit unit   = other.GetComponent <GameUnit>();
        GameUnit myself = this.GetComponentInParent <GameUnit>();

        if (unit != null)
        {
            Renderer unitRenderer = unit.GetComponent <Renderer>();
            if (myself != null && (unit != myself) && unitRenderer.enabled && !unit.hasAuthority && !this.enemiesInRange.Contains(unit))
            {
                this.enemiesInRange.Add(unit);
            }
        }

        AIUnit AIunit = other.GetComponent <AIUnit>();

        if (AIunit != null && !this.otherEnemies.Contains(AIunit))
        {
            this.otherEnemies.Add(AIunit);
        }

        if (this.exitedList.Count > 0)
        {
            this.exitedList.Clear();
        }
        if (this.exitedEnemies.Count > 0)
        {
            this.exitedEnemies.Clear();
        }
    }
示例#4
0
        public void SetUnit(GameUnit gameUnit)
        {
            _gameUnit = gameUnit;
            var navAgent = gameUnit.GetComponent <NavMeshAgent>();

            if (navAgent != null)
            {
                _unitOffset = Vector3.up * navAgent.height;
            }
        }
    public override void Activate(GameUnit source, List <GameUnit> targets)
    {
        Debug.Log("Activate ShieldShatter");

        source.GetComponent <Animator>().SetBool("swordStrikeTrigger", true);

        foreach (GameUnit target in targets)
        {
            target.TakeDamage(2);
        }
    }
示例#6
0
    public void OnTriggerExit(Collider other)
    {
        GameUnit unit = other.GetComponent <GameUnit>();

        if (unit != null)
        {
            Renderer unitRenderer = unit.GetComponent <Renderer>();
            if ((!unit.hasAuthority && this.enemiesInAttackRange.Contains(unit) && !unit.Equals(this.parent)) || (!unitRenderer.enabled && this.enemiesInAttackRange.Contains(unit)))
            {
                this.enemiesInAttackRange.Remove(unit);
                this.exitedList.Add(unit);
            }
        }
        else
        {
            AIUnit AIunit = other.GetComponent <AIUnit>();
            if (AIunit != null && this.otherEnemies.Contains(AIunit))
            {
                this.otherEnemies.Remove(AIunit);
            }
        }
    }
示例#7
0
 public override void Activate(GameUnit source, List <GameUnit> targets)
 {
     Debug.Log("Activate Block");
     source.GetComponent <Animator>().SetBool("helloTrigger", true);
     source.Shield += 5;
 }
    public IEnumerator NextTurn()
    {
        Debug.Log("Next turn!");
        WhoseTurnIsIt().GetComponent <GameUnit>().Sleep();
        ControlHandler.instance.controlLock = true;

        //If the boss just ended their turn, enter a special minion phase that lasts three seconds.
        if (playerTurn == 1 && MinionCount() > 0)
        {
            CameraMan.instance.ChangeCameraModes(CameraMan.CameraModes.Full);
            WhoseTurnIsIt().GetComponent <Boss> ().RefreshMinionCharges();
            Debug.Log("Special Minion Turn! Minion Count: " + minionsInGame.Count);
            for (int i = 0; i < minionsInGame.Count; i++)
            {
                Minion minion = minionsInGame [i].GetComponent <Minion>();
                minion.WakeUp();
                minion.RefreshMoves();
                minion.HuntAndPester();
                yield return(new WaitForSeconds(1f));
            }
            yield return(new WaitForSeconds(2));

            for (int i = 0; i < minionsInGame.Count; i++)
            {
                Minion minion = minionsInGame [i].GetComponent <Minion>();
                minion.Sleep();
            }
        }
        if (wispsInGame.Count > 0)
        {
            CameraMan.instance.ChangeCameraModes(CameraMan.CameraModes.Full);
            yield return(new WaitForSeconds(1f));

            Debug.Log("Special Wisp Turn! Wisp Count: " + wispsInGame.Count);
            for (int i = 0; i < wispsInGame.Count; i++)
            {
                Wisp wisp = wispsInGame [i].GetComponent <Wisp>();
                wisp.WakeUp();
                wisp.RefreshMoves();
                wisp.ScoutOrReturn();
                yield return(new WaitForSeconds(2.5f));
            }
            yield return(new WaitForSeconds(2));
        }
        CameraMan.instance.ChangeCameraModes(CameraMan.CameraModes.Follow);

        playerTurn++;

        if (playerTurn > 4)
        {
            playerTurn = 1;
        }

        while (!WhoseTurnIsIt().GetComponent <GameUnit> ().isAlive())
        {
            playerTurn++;
        }

        if (playerTurn > 4)
        {
            playerTurn = 1;
        }

        GameUnit playerInControl = WhoseTurnIsIt().GetComponent <GameUnit>();

        if (playerInControl.GetComponent <Player> () != null)
        {
            playerInControl.GetComponent <Player>().RefreshArrows();
        }
        playerInControl.RefreshMoves();
        CameraMan.instance.SetTarget(WhoseTurnIsIt().transform);
        playerInControl.WakeUp();
        GameTileManager.instance.UpdateActiveListBasedOnPlayerPosition(playerInControl);
        MenuController.instance.GetRoundStart().StartNewRound(playerInControl);
        yield return(new WaitForSeconds(0.5f));

        ControlHandler.instance.controlLock = false;
    }