コード例 #1
0
    void Awake()
    {
        _chr = GetComponentInParent <ChrController>();
        if (_chr == null)
        {
            this.enabled = false;
        }
        else
        {
            if (_chr.chrControllerType != ChrController.ChrControllerTypes.AI_Enemy && _chr.chrControllerType != ChrController.ChrControllerTypes.AI_Boss && _chr.chrControllerType != ChrController.ChrControllerTypes.AI_NPC)
            {
                this.enabled = false;
            }
            else
            {
                _canMelee   = GetComponent <IsAIMelee>();
                _canRange   = GetComponent <IsAIRange>();
                _canRage    = GetComponent <IsAIRager>();
                _canRetreat = GetComponent <IsAITactician>();
                _canEscort  = GetComponent <IsAISupporter>();
                _canPatrol  = GetComponent <IsAIPatrol>();
                _canDefend  = GetComponent <IsAIDefend>();
                _canPanic   = GetComponent <IsAIPanic>();

                if (_canPatrol)
                {
                    _patrolCtrl = GetComponent <IsAIPatrol>();
                }
                if (_canDefend)
                {
                    _defendCtrl = GetComponent <IsAIDefend>();
                }
            }
        }
    }
コード例 #2
0
ファイル: IsHitBox.cs プロジェクト: a2957360/Here-be-Dragons
    void DmgOther(Collider2D other)
    {
        ChrController otherCtrl = other.gameObject.GetComponent <ChrController>();

        if (otherCtrl != null && !otherCtrl._isDead && !otherCtrl._isHurt)
        {
            _oChr = otherCtrl;
            if (HitBoxAttackType == AttackTypes.PSlash && _chr.CurrentPrimaryAction == ChrController.PrimaryActionList.PSlash)
            {
                otherCtrl.TakeDmg(_self, 0, _chr._dmgSlash);
                //_chr._isAttacking = false;
                pushBack(1.0f, _chr._direction, other.gameObject);
            }
            else if (HitBoxAttackType == AttackTypes.PSlash2 && _chr.CurrentPrimaryAction == ChrController.PrimaryActionList.PSlash2)
            {
                otherCtrl.TakeDmg(_self, 0, _chr._dmgSlash2);
                //_chr._isAttacking = false;
                pushBack(1.2f, _chr._direction, other.gameObject);
            }
            else if (HitBoxAttackType == AttackTypes.PThrust && _chr.CurrentPrimaryAction == ChrController.PrimaryActionList.PThrust)
            {
                otherCtrl.TakeDmg(_self, 1, _chr._dmgThrust);
                //_chr._isAttacking = false;
                pushBack(1.2f, _chr._direction, other.gameObject);
            }
            else if (HitBoxAttackType == AttackTypes.PThrust && _chr.CurrentPrimaryAction == ChrController.PrimaryActionList.PThrust2)
            {
                otherCtrl.TakeDmg(_self, 1, _chr._dmgThrust2);
                //_chr._isAttacking = false;
                pushBack(1.5f, _chr._direction, other.gameObject);
            }
        }
    }
コード例 #3
0
    // type 1: hero 2: enemy
    public void FindUnit(int x, int y, int type)
    {
        if (MissionManager.Instance._missionOver || MissionManager.Instance._missionWin)
        {
            return;
        }
        ChrController unit = null;

        if (type == 1 && _playerPhase)
        {
            unit = _heros.Find(s => ((int)s._position.x == x) && ((int)s._position.y == y) && (s._turn < 200) && (!s._isDead));
            //MenuController.Instance.ShowSelectionList = true;
        }
        else if (type == 2 && _enemyPhase)
        {
            unit = _enemies.Find(s => ((int)s._position.x == x) && ((int)s._position.y == y) && (s._turn < 200) && (!s._isDead));
        }

        if (unit != null)
        {
            //if (unit._isDead)
            //{
            //    return;
            //}
            DeselectCurUnit();
            _curUnit = unit;
            _curUnit.UnitSelected();
            if (_playerPhase)
            {
                PlayerInputManager.Instance._inputMode = PlayerInputManager.InputModes.PathSelection;
            }
            //else if (_enemyPhase)
            //    AIDirector.Instance._pathSelectionMode = true;
        }
    }
コード例 #4
0
    //to check enemy movement and moved hero's movement
    public void FindUnitMovement(int x, int y)
    {
        if (MissionManager.Instance._missionOver || MissionManager.Instance._missionWin)
        {
            return;
        }
        ChrController unit = null;

        unit = _heros.Find(s => ((int)s._position.x == x) && ((int)s._position.y == y) && (s._turn > 200));
        if (unit == null)
        {
            unit = _enemies.Find(s => ((int)s._position.x == x) && ((int)s._position.y == y) && (s._turn < 200));
        }

        if (unit != null)
        {
            if (unit._isDead)
            {
                return;
            }
            DeselectCurUnit();
            _curUnit = unit;
            _curUnit.UnitCheckMovement();
        }
    }
コード例 #5
0
 public void CheckDeathEvent(int x, int y, int type)
 {
     if (_unitDefeated.Count > 0 && _unitDefeated.Count == _unitDefeatedEvent.Count)
     {
         bool found = false;
         for (int i = 0; !found && i < _unitDefeated.Count; i++)
         {
             ChrController actor1 = GameManager.Instance._heros.Find(h => h._name == _unitDefeated[i] && h._isDead);
             if (actor1 == null)
             {
                 actor1 = GameManager.Instance._enemies.Find(h => h._name == _unitDefeated[i] && h._isDead);
             }
             if (actor1 != null)
             {
                 EventManager.Instance.PlaySpecialEvent(_unitDefeatedEvent[i]);
                 found = true;
                 _unitDefeated.RemoveAt(i);
                 _unitDefeatedEvent.RemoveAt(i);
             }
         }
         if (!found)
         {
             GameManager.Instance.FinishUnitTurn(type);
         }
     }
     else
     {
         GameManager.Instance.FinishUnitTurn(type);
     }
 }
コード例 #6
0
    private void EnemyActions()
    {
        _roundStatusText.gameObject.SetActive(false);
        if (_imageDarken != null)
        {
            _imageDarken.SetActive(false);
        }
        if (_enemies.Count > 0)
        {
            SortList(_enemies);

            if (_enemies[0]._turn >= 200)
            {
                NewRound();
            }
            else
            {
                _curUnit = _enemies[0];
                _curUnit.UnitSelected();
                AIDirector.Instance.DecideAction(_curUnit);
            }
        }
        else
        {
        }
    }
コード例 #7
0
 private void Awake()
 {
     _chr = GetComponent <ChrController>();
     if (_chr == null)
     {
         this.enabled = false;
     }
 }
コード例 #8
0
ファイル: StellaMove.cs プロジェクト: dat19/GreeningEx2019
        /// <summary>
        /// 設定した動きをキャラクターコントローラーに反映。
        /// </summary>
        public void Move()
        {
            // 設定された速度を反映
            stellaAnimator.SetFloat("VelX", Mathf.Abs(myVelocity.x));
            stellaAnimator.SetFloat("VelY", myVelocity.y);

            Vector3 move = myVelocity * Time.fixedDeltaTime;

            // Zを調整
            float distZ = Mathf.Abs(transform.position.z);

            if (distZ >= abortMinDistance)
            {
                distZ  = Mathf.Min(distZ, MoveSpeed * Time.fixedDeltaTime);
                move.z = distZ * Mathf.Sign(-transform.position.z);
            }

            float lastY = transform.position.y;

            // 端の移動制限
            move.x = StageOverCheck(move.x);
            ChrController.Move(move);

            IsHitHead = false;
            if (!ChrController.isGrounded)
            {
                if (move.y > ChrController.minMoveDistance)
                {
                    if (Mathf.Approximately(lastY, transform.position.y))
                    {
                        IsHitHead = true;
                    }
                }
                else if (stellaActionScriptableObjects[(int)NowAction].canStepDown)
                {
                    // 歩き時は、乗り越えられる段差の高さ分、落下を許容する
                    move.Set(0, -ChrController.stepOffset - move.y, 0);
                    ChrController.Move(move);
                }
            }

#if DEBUG_DIFF_Y
            Debug.Log($"  StellaMove.Move {ChrController.collisionFlags} / move={move} / hit head={IsHitHead}");
            Debug.Log($"  y={transform.position.y-lastY}");
#endif

            // ステージ外チェック
            if (ChrController.bounds.max.y < StageManager.StageBottom)
            {
                // ミスにする
                GameParams.isMiss = true;
                ChangeAction(ActionType.Obore);
                return;
            }

            stellaAnimator.SetBool("IsGrounded", ChrController.isGrounded);
        }
コード例 #9
0
ファイル: IsHitBox.cs プロジェクト: a2957360/Here-be-Dragons
 // Use this for initialization
 void Awake()
 {
     _self = transform.root.gameObject;
     _boxy = GetComponent <BoxCollider2D>();
     _chr  = GetComponentInParent <ChrController>();
     if (_boxy == null || _chr == null)
     {
         gameObject.SetActive(false);
     }
 }
コード例 #10
0
ファイル: EventManager.cs プロジェクト: a2957360/Crimson
    public void ChangeTrueBossBehavior(int pattern)
    {
        ChrController chr = GameManager.Instance._enemies.Find(e => e._name == "Mercurius");

        //Debug.Log(chr);
        if (chr != null)
        {
            chr.ChangeAIPattern(pattern);
        }
    }
コード例 #11
0
 /*
  * Phase
  * 0: PlayerPhase
  * 1: EnemyPhase
  * */
 public void SpawnUnit(int round)
 {
     if (_active && round >= _startRound && _numSpawn < _totalSpawn && _mission == GameManager.Instance._level)
     {
         if (_coolDownCount >= _coolDown)
         {
             Cell curCell = GameManager.Instance.GetCell(_locationX, _locationY);
             if (curCell != null && curCell._cost < 10)
             {
                 GameObject toInstantiate = _spawnList[Random.Range(0, _spawnList.Count)];
                 GameObject instance      = Instantiate(toInstantiate, new Vector3(_locationX, _locationY, 0f), Quaternion.identity) as GameObject;
                 GameManager.Instance.ChangeCellCost(_locationX, _locationY, _playerSide ? 1 : 2, 10);
                 ChrController chr = instance.GetComponent <ChrController>();
                 if (chr != null)
                 {
                     if (_playerSide)
                     {
                         GameManager.Instance._heros.Add(chr);
                         MissionManager.Instance._numHeroes++;
                         GameObject heroHolder = GameObject.Find("Hero");
                         if (heroHolder != null)
                         {
                             instance.transform.SetParent(heroHolder.transform);
                         }
                     }
                     else
                     {
                         //chr._AIPattern = ChrController.AIPatterns.Approach;
                         chr.ChangeAIPattern((int)_SpawnAIPattern);
                         GameManager.Instance._enemies.Add(chr);
                         MissionManager.Instance._numEnemies++;
                         GameObject enemyHolder = GameObject.Find("Enemy");
                         if (enemyHolder != null)
                         {
                             instance.transform.SetParent(enemyHolder.transform);
                         }
                     }
                 }
                 _coolDownCount = 0;
                 _numSpawn++;
                 if (_spawnDialogue)
                 {
                     _spawnDialogue = false;
                     MissionManager.Instance._spawnEvent = _spawnEvent;
                 }
             }
         }
         else
         {
             _coolDownCount++;
         }
     }
 }
コード例 #12
0
    public void CheckMeetingEvent(int x, int y, int type)
    {
        if ((_ecounterEvents.Count) > 0 && (_ecounterEvents.Count == _ecounterActors1.Count) && (_ecounterEvents.Count == _ecounterActors2.Count))
        {
            bool found = false;
            for (int i = 0; !found && i < _ecounterEvents.Count; i++)
            {
                ChrController actor1 = GameManager.Instance._heros.Find(h => h._name == _ecounterActors1[i] && !h._isDead);
                if (actor1 == null)
                {
                    actor1 = GameManager.Instance._enemies.Find(h => h._name == _ecounterActors1[i] && !h._isDead);
                }

                if (actor1 != null)
                {
                    ChrController actor2 = GameManager.Instance._heros.Find(h => h._name == _ecounterActors2[i] && !h._isDead);
                    if (actor2 == null)
                    {
                        actor2 = GameManager.Instance._enemies.Find(h => h._name == _ecounterActors2[i] && !h._isDead);
                    }

                    if (actor2 != null)
                    {
                        if (CalcDistance(actor1._position, actor2._position) <= 1)
                        {
                            EventManager.Instance.PlaySpecialEvent(_ecounterEvents[i]);
                            found = true;
                            _ecounterActors1.RemoveAt(i);
                            _ecounterActors2.RemoveAt(i);
                            _ecounterEvents.RemoveAt(i);
                        }
                        else if (CalcDistance(actor1._position, actor2._position) == 2 && Random.Range(0, 10) > 6)
                        {
                            EventManager.Instance.PlaySpecialEvent(_ecounterEvents[i]);
                            found = true;
                            _ecounterActors1.RemoveAt(i);
                            _ecounterActors2.RemoveAt(i);
                            _ecounterEvents.RemoveAt(i);
                        }
                    }
                }
            }
            if (!found)
            {
                CheckDeathEvent(x, y, type);
            }
        }
        else
        {
            CheckDeathEvent(x, y, type);
        }
    }
コード例 #13
0
 public void Activebuff(ChrController curunit)
 {
     if (curunit._Brave > 0)
     {
         AtkUp.SetActive(true);
     }
     else
     {
         AtkUp.SetActive(false);
     }
     if (curunit._Brave < 0)
     {
         AtkDown.SetActive(true);
     }
     else
     {
         AtkDown.SetActive(false);
     }
     if (curunit._Protect > 0)
     {
         DefUp.SetActive(true);
     }
     else
     {
         DefUp.SetActive(false);
     }
     if (curunit._Protect < 0)
     {
         DefDown.SetActive(true);
     }
     else
     {
         DefDown.SetActive(false);
     }
     if (curunit._Speed > 0)
     {
         AglUp.SetActive(true);
     }
     else
     {
         AglUp.SetActive(false);
     }
     if (curunit._Speed < 0)
     {
         AglDown.SetActive(true);
     }
     else
     {
         AglDown.SetActive(false);
     }
 }
コード例 #14
0
 void CheckLossConditions()
 {
     if (_numHeroes <= 0)
     {
         _missionOver = true;
         MissionOverProcessing(0);
     }
     if (!_missionOver && GameManager.Instance._round > _maxRound)
     {
         _missionOver = true;
         MissionOverProcessing(2);
     }
     if (!_missionOver)
     {
         List <ChrController> bosses = GameManager.Instance._enemies.FindAll(e => (e._unitType == ChrController.UnitTypes.Enemy_Boss) && !e._isDead);
         foreach (ChrController boss in bosses)
         {
             if (CalcDistance(boss._position, _enemyEscapeLocation) < 1)
             {
                 _enemyEscaped = true;
             }
         }
         _missionOver = _enemyEscaped;
         if (_missionOver)
         {
             MissionOverProcessing(3);
         }
     }
     if (!_missionOver && _heroVIPs.Count > 0)
     {
         foreach (string hero in _heroVIPs)
         {
             ChrController chr = GameManager.Instance._heros.Find(h => h._name == hero);
             if (chr != null)
             {
                 if (chr._isDead)
                 {
                     _missionOver = true;
                     if (chr._unitType == ChrController.UnitTypes.Hero_Main)
                     {
                         MissionOverProcessing(1);
                     }
                     else
                     {
                         MissionOverProcessing(0);
                     }
                 }
             }
         }
     }
 }
コード例 #15
0
    public void CenterOnUnit(bool player)
    {
        ChrController chr = null;

        if (player)
        {
            chr = _heros.Find(h => (h._isDead == false) && h._name == "Agnes");
        }
        //else
        //    chr = _enemies.Find(h => h._isDead == false);
        if (chr != null)
        {
            CameraManager.Instance.FollowTargetByVector(chr._position);
        }
    }
コード例 #16
0
 public void DeselectCurUnit()
 {
     if (_curUnit != null)
     {
         _curUnit.UnitDeSelected();
     }
     _curUnit        = null;
     _curEnemy       = null;
     _curPlayerEnemy = null;
     if (_playerPhase)
     {
         PlayerInputManager.Instance._inputMode = PlayerInputManager.InputModes.ChrSelection;
     }
     //else if (_enemyPhase)
     //    AIDirector.Instance._pathSelectionMode = false;
 }
コード例 #17
0
    //Vector2 _attPos;
    #endregion

    #region Gameflow

    #endregion

    #region Functions

    public void DecideAction(ChrController unit)
    {
        _curUnit = unit;
        if (unit._turn < 200)
        {
            _target = AStarPathfinding.Instance.FindRandomTarget();
            if (_curUnit._AIPattern == ChrController.AIPatterns.Guard && _target == null)
            {
                Invoke("DecideActionDelay", _delay * 0.5f);
            }
            else
            {
                Invoke("DecideActionDelay", _delay);
            }
        }
    }
コード例 #18
0
ファイル: IsNetwork.cs プロジェクト: a2957360/Here-be-Dragons
    public override void OnStartLocalPlayer()
    {
        _chr = GetComponent <ChrController>();

        if (_localPlayerIcon != null && _chr.chrControllerType == ChrController.ChrControllerTypes.Player)
        {
            _localPlayerIcon.SetActive(true);
        }

        //GetComponent<NetworkAnimator>().SetParameterAutoSend(0, true);
        //Renderer[] rens = gameObject.GetComponentsInChildren<Renderer>();
        //foreach (Renderer ren in rens)
        //{
        //    ren.enabled = false;
        //}
    }
コード例 #19
0
 void GameOverProcess()
 {
     if (!_gameOverProcessStarted)
     {
         if (isServer)
         {
             Googlegameserver.Addacheivement(GPGSIds.achievement_finish_first_battle);
             GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
             foreach (GameObject obj in enemies)
             {
                 ChrController chrCtrl = obj.GetComponent <ChrController>();
                 if (chrCtrl != null && !chrCtrl._isDead)
                 {
                     chrCtrl.Death(false);
                 }
             }
             GameObject[] allies = GameObject.FindGameObjectsWithTag("Player");
             foreach (GameObject obj in allies)
             {
                 ChrController chrCtrl = obj.GetComponent <ChrController>();
                 if (chrCtrl != null && !chrCtrl._isDead && chrCtrl.chrControllerType == ChrController.ChrControllerTypes.AI_NPC)
                 {
                     chrCtrl.Death(false);
                 }
             }
             if (_score > _highScore)
             {
                 _highScore = _score;
                 Rpc_DisplayScore();
             }
             _gameOverProcessStarted = true;
             Rpc_RoundEnd();
             if (_gameOver)
             {
                 Googlegameserver.Addacheivement(GPGSIds.achievement_first_death);
             }
             else if (_gameWin)
             {
                 Googlegameserver.Addacheivement(GPGSIds.achievement_win_your_first_battle);
             }
         }
     }
     else
     {
         GameRestart();
     }
 }
コード例 #20
0
ファイル: LoadBoardFromXML.cs プロジェクト: a2957360/Crimson
    /*
     * Type:
     * 0: Obstacle
     * 1: Hero
     * 2: Enemy
     * */
    //LayoutObjectAtRandom accepts an array of game objects to choose from along with a minimum and maximum range for the number of objects to create.
    void LayoutObject(int num, Vector3 positon, int type)
    {
        switch (type)
        {
        case 0:
        {
            GameObject instance = Instantiate(itemTiles[num], positon, Quaternion.identity);
            instance.transform.SetParent(obstacleHolder);
            GameManager.Instance.ChangeCellCost((int)positon.x, (int)positon.y, type, 20);
        }
        break;

        case 1:
        {
            GameObject instance = Instantiate(heroTiles[num - 1], positon, Quaternion.identity);
            instance.transform.SetParent(heroHolder);
            ChrController chr = instance.GetComponent <ChrController>();
            if (chr != null)
            {
                //chr._MovementRange = 6;
                GameManager.Instance._heros.Add(chr);
            }
            GameManager.Instance.ChangeCellCost((int)positon.x, (int)positon.y, type, 10);
        }
        break;

        case 2:
        {
            GameObject instance = Instantiate(enemyTiles[num - 1], positon, Quaternion.identity);
            instance.transform.SetParent(enemyHolder);
            ChrController chr = instance.GetComponent <ChrController>();
            if (chr != null)
            {
                //chr._MovementRange = Random.Range(2, 5);
                GameManager.Instance._enemies.Add(chr);
            }
            GameManager.Instance.ChangeCellCost((int)positon.x, (int)positon.y, type, 10);
        }
        break;
        }
    }
コード例 #21
0
    public void FinishUnitTurn(int type)
    {
        //SpillBlood((int)_curUnit._position.x, (int)_curUnit._position.y, UnityEngine.Random.Range(1, 6), false);
        ChrController temp = _curUnit;

        DeselectCurUnit();
        //PlayerInputManager.Instance._inputMode = PlayerInputManager.InputModes.ChrSelection;
        //else if (type == 2)
        //    AIDirector.Instance._watchMode = false;

        MissionManager.Instance.CheckMissionComplete();

        if (!MissionManager.Instance._missionOver && !MissionManager.Instance._missionWin)
        {
            if (type == 1)
            {
                if (_heros.Count > 0)
                {
                    PlayerTurnTrulyFinished();
                    //if (_momentumReached && temp != null && !temp._isDead)
                    //{
                    //    temp.NewTurnStarted();
                    //    _momentum = 0;
                    //    _momentumReached = false;
                    //    UpdateMomentumText();
                    //    Invoke("MomentumMiniGame", 0.1f);
                    //}
                    //else
                    //{
                    //    PlayerTurnTrulyFinished();
                    //}
                }
            }
            else if (type == 2)
            {
                //EnemyActions();
                Invoke("EnemyActions", _enemyActionAfterDelay);
            }
        }
    }
コード例 #22
0
    // type 1: hero 2: enemy
    public ChrController CheckUnit(int x, int y, int type)
    {
        ChrController unit = null;

        if (type == 1)
        {
            unit = _heros.Find(s => ((int)s._position.x == x) && ((int)s._position.y == y) && (s._isDead == false));
        }
        else if (type == 2)
        {
            unit = _enemies.Find(s => ((int)s._position.x == x) && ((int)s._position.y == y) && (s._isDead == false));
        }

        //if (unit != null)
        //{
        //    if (unit._isDead)
        //    {
        //        return null;
        //    }
        //}
        return(unit);
    }
コード例 #23
0
    void GameRestart()
    {
        _gameOverTimer += Time.deltaTime;

        if (_gameOverTimer >= _gameOverDuration)
        {
            _gameOverProcessStarted = false;
            _gameOverTimer          = 0.0f;
            if (_gameOver)
            {
                _score = 0;
                Rpc_DisplayScore();
                _level = 1;
            }
            else
            {
                _level++;
            }
            _gameOver     = false;
            _gameWin      = false;
            _roundStarted = false;
            _ClockCurrent = _roundDuration;

            if (isServer)
            {
                _lvReset = true;
                GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
                foreach (GameObject obj in players)
                {
                    ChrController chrCtrl = obj.GetComponent <ChrController>();
                    if (chrCtrl != null && chrCtrl.chrControllerType == ChrController.ChrControllerTypes.Player)
                    {
                        chrCtrl.Respawn();
                    }
                }
            }
            Rpc_RoundRestart();
        }
    }
コード例 #24
0
    void OnTriggerEnter2D(Collider2D other)
    {
        string nameTag = other.gameObject.tag;

        if (other.gameObject.layer == 8)
        {
            Destroy(gameObject);
        }
        else if (!other.isTrigger)
        {
            if ((_dmgTarget == DamageTargets.Player && nameTag == "Player") || (_dmgTarget == DamageTargets.Enemy && nameTag == "Enemy"))
            {
                gameObject.GetComponent <SpriteRenderer>().enabled = false;
                _oChr = other.gameObject.GetComponent <ChrController>();
                if (_oChr != null)
                {
                    _oChr.TakeDmg(_caster, _isSpell ? 2 : 1, _damage);
                    Invoke("InvokePushBack", 0.1f);
                    Destroy(gameObject, 0.15f);
                }
            }
        }
    }
コード例 #25
0
    public void UpdateStatsAndSetColor(ChrController chr)
    {
        if (chr._Attack > chr._BaseAttack)
        {
            Atk.color     = Color.green;
            AtkText.color = Color.green;
        }
        else if (chr._Attack < chr._BaseAttack)
        {
            Atk.color     = Color.red;
            AtkText.color = Color.red;
        }
        else
        {
            Atk.color     = Color.black;
            AtkText.color = Color.black;
        }

        if (chr._Defense > chr._BaseDefense)
        {
            Def.color     = Color.green;
            DefText.color = Color.green;
        }
        else if (chr._Defense < chr._BaseDefense)
        {
            Def.color     = Color.red;
            DefText.color = Color.red;
        }
        else
        {
            Def.color     = Color.black;
            DefText.color = Color.black;
        }

        if (chr._Agility > chr._BaseAgility)
        {
            Agl.color     = Color.green;
            AglText.color = Color.green;
        }
        else if (chr._Agility < chr._BaseAgility)
        {
            Agl.color     = Color.red;
            AglText.color = Color.red;
        }
        else
        {
            Agl.color     = Color.black;
            AglText.color = Color.black;
        }

        if (chr._MovementRange > chr._BaseMovementRange)
        {
            Mov.color     = Color.green;
            MovText.color = Color.green;
        }
        else if (chr._MovementRange < chr._BaseMovementRange)
        {
            Mov.color     = Color.red;
            MovText.color = Color.red;
        }
        else
        {
            Mov.color     = Color.black;
            MovText.color = Color.black;
        }

        Atk.text = chr._Attack.ToString();
        Def.text = chr._Defense.ToString();
        Agl.text = chr._Agility.ToString();
        Mov.text = chr._MovementRange.ToString();
    }
コード例 #26
0
 public void SetTargetCell(Vector2 pos, Vector2 attPos, ChrController chr)
 {
     _targetChr = chr;
     _position  = pos;
     AddAttackPosition(attPos);
 }
コード例 #27
0
ファイル: EventManager.cs プロジェクト: a2957360/Crimson
    public void PlayDialogue()
    {
        Event.Dialogue dia = _curEvent._dialogueLines[_curIndex];

        if (dia._targetName != "")
        {
            ChrController chr = GameManager.Instance._heros.Find(h => h._name == dia._targetName && !h._isDead);
            if (chr == null)
            {
                chr = GameManager.Instance._enemies.Find(h => h._name == dia._targetName && !h._isDead);
            }

            if (chr != null)
            {
                CameraManager.Instance.FollowTargetByVector(chr._position);
            }
        }
        else if (dia._x != -1 && dia._y != -1)
        {
            CameraManager.Instance.FollowTargetByVector(new Vector2(dia._x, dia._y));
        }

        if (dia._isImage)
        {
            if (_curEvent._trigger == Event.TriggerTypes.Story_Explain)
            {
                if (_richTextImage2 != null)
                {
                    _richTextImage2.gameObject.SetActive(true);
                    _richTextImage2.sprite = _richTextEvents[dia._speakerNum];
                }
                if (_ImageDarken != null)
                {
                    _ImageDarken.gameObject.SetActive(true);
                }
                _centerLDialogueUI.SetActive(true);
                _centerLText.text = _curEvent._lines[dia._line];
                _eventBG.gameObject.SetActive(true);
                _eventBG.sprite = _eventBGs[dia._BG];
            }
            else if (_curEvent._trigger == Event.TriggerTypes.GameState || _curEvent._trigger == Event.TriggerTypes.GameState_End)
            {
                if (_richTextImage != null)
                {
                    _richTextImage.gameObject.SetActive(true);

                    if (!_curEvent._useTutorialImages)
                    {
                        _richTextImage.sprite = _richTextImages[dia._speakerNum];
                    }
                    else
                    {
                        _richTextImage.sprite = _tutorialEvents[dia._speakerNum];
                    }
                }
            }
            else
            {
                if (_richTextImage2 != null)
                {
                    _richTextImage2.gameObject.SetActive(true);
                    if (_curEvent._trigger == Event.TriggerTypes.UnitDefeat ||
                        _curEvent._trigger == Event.TriggerTypes.MissionLoss ||
                        _curEvent._trigger == Event.TriggerTypes.MissionWin)
                    {
                        _richTextImage2.sprite = _richTextEvents[dia._speakerNum];
                    }
                    else
                    {
                        if (_curEvent._useTutorialImages ||
                            _curEvent._trigger == Event.TriggerTypes.Tutorial ||
                            _curEvent._trigger == Event.TriggerTypes.BattleTutorial)
                        {
                            _richTextImage2.sprite = _tutorialEvents[dia._speakerNum];
                        }
                        else
                        {
                            _richTextImage2.sprite = _richTextImages[dia._speakerNum];
                        }
                    }
                    if (_ImageDarken != null)
                    {
                        _ImageDarken.gameObject.SetActive(true);
                    }
                }
            }
        }
        else
        {
            if (dia._leftSide)
            {
                if (_curEvent._trigger == Event.TriggerTypes.GameState || _curEvent._trigger == Event.TriggerTypes.GameState_End)
                {
                    _eventBG.gameObject.SetActive(true);
                    _eventBG.sprite = _eventBGs[dia._BG];
                    _leftLDialogueUI.SetActive(true);
                    if (dia._speakerNum < _LPortraits.Count)
                    {
                        _leftLSpeaker.sprite = _LPortraits[dia._speakerNum];
                    }
                    _leftLText.text = _curEvent._lines[dia._line];
                    SetAlpha(_leftLTextBG, true);
                    SetAlphaText(_leftLText, true);
                    SetAlpha(_rightLTextBG, false);
                    SetAlphaText(_rightLText, false);
                    if (_waitMode)
                    {
                        _leftLConfirm.SetActive(true);
                        _rightLConfirm.SetActive(false);
                    }
                }
                else
                {
                    _leftDialogueUI.SetActive(true);
                    if (_curEvent._trigger != Event.TriggerTypes.Battle)
                    {
                        if (dia._speakerNum < _SPortraits.Count)
                        {
                            _leftSpeaker.sprite = _SPortraits[dia._speakerNum];
                        }
                    }
                    _leftText.text = _curEvent._lines[dia._line];
                    SetAlpha(_leftTextBG, true);
                    SetAlphaText(_leftText, true);
                    SetAlpha(_rightTextBG, false);
                    SetAlphaText(_rightText, false);
                    if (_waitMode)
                    {
                        _leftConfirm.SetActive(true);
                        _rightConfirm.SetActive(false);
                    }
                }
            }
            else
            {
                if (_curEvent._trigger == Event.TriggerTypes.GameState || _curEvent._trigger == Event.TriggerTypes.GameState_End)
                {
                    _eventBG.gameObject.SetActive(true);
                    _eventBG.sprite = _eventBGs[dia._BG];
                    _rightLDialogueUI.SetActive(true);
                    if (dia._speakerNum < _LPortraits.Count)
                    {
                        _rightLSpeaker.sprite = _LPortraits[dia._speakerNum];
                    }
                    _rightLText.text = _curEvent._lines[dia._line];
                    SetAlpha(_leftLTextBG, false);
                    SetAlphaText(_leftLText, false);
                    SetAlpha(_rightLTextBG, true);
                    SetAlphaText(_rightLText, true);
                    if (_waitMode)
                    {
                        _leftLConfirm.SetActive(false);
                        _rightLConfirm.SetActive(true);
                    }
                }
                else
                {
                    _rightDialogueUI.SetActive(true);
                    if (_curEvent._trigger != Event.TriggerTypes.Battle)
                    {
                        if (dia._speakerNum < _SPortraits.Count)
                        {
                            _rightSpeaker.sprite = _SPortraits[dia._speakerNum];
                        }
                    }
                    _rightText.text = _curEvent._lines[dia._line];
                    SetAlpha(_leftTextBG, false);
                    SetAlphaText(_leftText, false);
                    SetAlpha(_rightTextBG, true);
                    SetAlphaText(_rightText, true);
                    if (_waitMode)
                    {
                        _leftConfirm.SetActive(false);
                        _rightConfirm.SetActive(true);
                    }
                }
            }
        }

        if (dia._sendEvent && _curEvent._targetFunc.Count > 0)
        {
            for (int i = 0; i < _curEvent._targetFunc.Count; i++)
            {
                SendMessage(_curEvent._targetFunc[i], _curEvent._funcPara[i]);
            }
        }
        //if (!_waitMode)
        //    Invoke("PlayEventNextPart", _autoPlayTime);
    }
コード例 #28
0
    void setproporty()
    {
        if (isPlayerBar)
        {
            ChrController curchr = null;
            if (GameManager.Instance._playerPhase)
            {
                curchr = GameManager.Instance._curUnit;
            }
            else
            {
                curchr = GameManager.Instance._curPlayerEnemy;
            }
            if (GameManager.Instance._playerPhase && curchr != null)
            {
                if (CombatManager.Instance._progress == CombatManager.BattleProgress.None && (curchr.gameObject.tag == "Enemy" || curchr._turn >= 200))
                {
                    curchr = null;
                }
            }
            if (curchr == null && GameManager.Instance._playerPhase && PlayerInputManager.Instance._HeroCursorHover != null)
            {
                curchr = PlayerInputManager.Instance._HeroCursorHover;
            }
            if (curchr != null)
            {
                WholeUI.SetActive(true);
                Photo.sprite = curchr._portrait;
                Name.text    = curchr._name;

                HP.text          = curchr._HP_Display.ToString();
                HPBar.fillAmount = (float)curchr._HP_Display / (float)curchr._maxHP;


                //Atk.text = curchr._Attack.ToString();
                //Def.text = curchr._Defense.ToString();
                //Agl.text = curchr._Agility.ToString();
                //Mov.text = curchr._MovementRange.ToString();
                UpdateStatsAndSetColor(curchr);
                RoleIcon.sprite = curchr._icon;
                if (curchr._Brave > 0)
                {
                    AtkUp.SetActive(true);
                }
                else
                {
                    AtkUp.SetActive(false);
                }
                if (curchr._Brave < 0)
                {
                    AtkDown.SetActive(true);
                }
                else
                {
                    AtkDown.SetActive(false);
                }
                if (curchr._Protect > 0)
                {
                    DefUp.SetActive(true);
                }
                else
                {
                    DefUp.SetActive(false);
                }
                if (curchr._Protect < 0)
                {
                    DefDown.SetActive(true);
                }
                else
                {
                    DefDown.SetActive(false);
                }
                if (curchr._Speed > 0)
                {
                    AglUp.SetActive(true);
                }
                else
                {
                    AglUp.SetActive(false);
                }
                if (curchr._Speed < 0)
                {
                    AglDown.SetActive(true);
                }
                else
                {
                    AglDown.SetActive(false);
                }
                if (CombatManager.Instance._isOffensiveBattle == true)
                {
                    if (CombatManager.Instance._isBattleSelectPhase == false)
                    {
                        BattleIconText.text = "";
                        BattleIcon.SetActive(false);
                        return;
                    }
                    BattleIcon.SetActive(true);
                    Power.SetActive(false);
                    Precision.SetActive(false);
                    Technique.SetActive(false);
                    Atkrandom.SetActive(false);
                    Block.SetActive(false);
                    Counter.SetActive(false);
                    Dodge.SetActive(false);
                    Defrandom.SetActive(false);
                    BattleIconText.text = "Favorite\nOffense";
                    switch (curchr._Fav_Offensive)
                    {
                    case ChrController.Fav_Offensives.Power:
                        BattleIcon.GetComponent <Image>().sprite = Power.GetComponent <Image>().sprite;
                        break;

                    case ChrController.Fav_Offensives.Precision:
                        BattleIcon.GetComponent <Image>().sprite = Precision.GetComponent <Image>().sprite;
                        break;

                    case ChrController.Fav_Offensives.Technical:
                        BattleIcon.GetComponent <Image>().sprite = Technique.GetComponent <Image>().sprite;
                        break;

                    case ChrController.Fav_Offensives.Random:
                        BattleIcon.GetComponent <Image>().sprite = Atkrandom.GetComponent <Image>().sprite;
                        break;
                    }
                }
                else if (CombatManager.Instance._isDefensiveBattle == true)
                {
                    if (CombatManager.Instance._isBattleSelectPhase == false)
                    {
                        BattleIconText.text = "";
                        BattleIcon.SetActive(false);
                        return;
                    }
                    BattleIcon.SetActive(true);
                    Power.SetActive(false);
                    Precision.SetActive(false);
                    Technique.SetActive(false);
                    Atkrandom.SetActive(false);
                    Block.SetActive(false);
                    Counter.SetActive(false);
                    Dodge.SetActive(false);
                    Defrandom.SetActive(false);
                    BattleIconText.text = "Favorite\nDefense";
                    switch (curchr._Fav_Defense)
                    {
                    case ChrController.Fav_Defenses.Guard:
                        BattleIcon.GetComponent <Image>().sprite = Block.GetComponent <Image>().sprite;
                        break;

                    case ChrController.Fav_Defenses.Counter:
                        BattleIcon.GetComponent <Image>().sprite = Counter.GetComponent <Image>().sprite;
                        break;

                    case ChrController.Fav_Defenses.Dodge:
                        BattleIcon.GetComponent <Image>().sprite = Dodge.GetComponent <Image>().sprite;
                        break;

                    case ChrController.Fav_Defenses.Random:
                        BattleIcon.GetComponent <Image>().sprite = Defrandom.GetComponent <Image>().sprite;
                        break;
                    }
                }
                else
                {
                    BattleIcon.SetActive(false);
                    BattleIconText.text = "Favorite\nTactics";
                    switch (curchr._Fav_Offensive)
                    {
                    case ChrController.Fav_Offensives.Power:
                        Power.SetActive(true);
                        Precision.SetActive(false);
                        Technique.SetActive(false);
                        Atkrandom.SetActive(false);
                        break;

                    case ChrController.Fav_Offensives.Precision:
                        Power.SetActive(false);
                        Precision.SetActive(true);
                        Technique.SetActive(false);
                        Atkrandom.SetActive(false);
                        break;

                    case ChrController.Fav_Offensives.Technical:
                        Power.SetActive(false);
                        Precision.SetActive(false);
                        Technique.SetActive(true);
                        Atkrandom.SetActive(false);
                        break;

                    case ChrController.Fav_Offensives.Random:
                        Power.SetActive(false);
                        Precision.SetActive(false);
                        Technique.SetActive(false);
                        Atkrandom.SetActive(true);
                        break;
                    }
                    switch (curchr._Fav_Defense)
                    {
                    case ChrController.Fav_Defenses.Guard:
                        Block.SetActive(true);
                        Counter.SetActive(false);
                        Dodge.SetActive(false);
                        Defrandom.SetActive(false);
                        break;

                    case ChrController.Fav_Defenses.Counter:
                        Block.SetActive(false);
                        Counter.SetActive(true);
                        Dodge.SetActive(false);
                        Defrandom.SetActive(false);
                        break;

                    case ChrController.Fav_Defenses.Dodge:
                        Block.SetActive(false);
                        Counter.SetActive(false);
                        Dodge.SetActive(true);
                        Defrandom.SetActive(false);
                        break;

                    case ChrController.Fav_Defenses.Random:
                        Block.SetActive(false);
                        Counter.SetActive(false);
                        Dodge.SetActive(false);
                        Defrandom.SetActive(true);
                        break;
                    }
                }
            }
            else
            {
                WholeUI.SetActive(false);
            }
        }
        else
        {
            ChrController curchr = null;
            if (GameManager.Instance._playerPhase)
            {
                curchr = GameManager.Instance._curEnemy;
                if (curchr == null && PlayerInputManager.Instance._EnemyCursorHover != null)
                {
                    curchr = PlayerInputManager.Instance._EnemyCursorHover;
                }
            }
            else if (GameManager.Instance._enemyPhase)
            {
                curchr = GameManager.Instance._curUnit;
            }
            if (curchr != null)
            {
                WholeUI.SetActive(true);
                Photo.sprite = curchr._portrait;
                Name.text    = curchr._name;

                HP.text          = curchr._HP_Display.ToString();
                HPBar.fillAmount = (float)curchr._HP_Display / (float)curchr._maxHP;
                //if (delayHpTimer > 0)
                //{
                //    delayHpTimer -= Time.deltaTime;
                //    return;
                //}
                //else
                //{
                //    HP.text = curchr._HP_Display.ToString();
                //    HPBar.fillAmount = curchr._HP_Display / curchr._maxHP;
                //    delayHpTimer = 0.4f;
                //}
                //Atk.text = curchr._Attack.ToString();
                //Def.text = curchr._Defense.ToString();
                //Agl.text = curchr._Agility.ToString();
                //Mov.text = curchr._MovementRange.ToString();
                UpdateStatsAndSetColor(curchr);
                RoleIcon.sprite = curchr._icon;
                if (curchr._Brave > 0)
                {
                    AtkUp.SetActive(true);
                }
                else
                {
                    AtkUp.SetActive(false);
                }
                if (curchr._Brave < 0)
                {
                    AtkDown.SetActive(true);
                }
                else
                {
                    AtkDown.SetActive(false);
                }
                if (curchr._Protect > 0)
                {
                    DefUp.SetActive(true);
                }
                else
                {
                    DefUp.SetActive(false);
                }
                if (curchr._Protect < 0)
                {
                    DefDown.SetActive(true);
                }
                else
                {
                    DefDown.SetActive(false);
                }
                if (curchr._Speed > 0)
                {
                    AglUp.SetActive(true);
                }
                else
                {
                    AglUp.SetActive(false);
                }
                if (curchr._Speed < 0)
                {
                    AglDown.SetActive(true);
                }
                else
                {
                    AglDown.SetActive(false);
                }
                if (CombatManager.Instance._isOffensiveBattle == true)
                {
                    if (CombatManager.Instance._isBattleSelectPhase == false)
                    {
                        BattleIconText.text = "";
                        BattleIcon.SetActive(false);
                        return;
                    }
                    BattleIcon.SetActive(true);
                    Power.SetActive(false);
                    Precision.SetActive(false);
                    Technique.SetActive(false);
                    Atkrandom.SetActive(false);
                    Block.SetActive(false);
                    Counter.SetActive(false);
                    Dodge.SetActive(false);
                    Defrandom.SetActive(false);
                    BattleIconText.text = "Favorite\nDefense";
                    switch (curchr._Fav_Defense)
                    {
                    case ChrController.Fav_Defenses.Guard:
                        BattleIcon.GetComponent <Image>().sprite = Block.GetComponent <Image>().sprite;
                        break;

                    case ChrController.Fav_Defenses.Counter:
                        BattleIcon.GetComponent <Image>().sprite = Counter.GetComponent <Image>().sprite;
                        break;

                    case ChrController.Fav_Defenses.Dodge:
                        BattleIcon.GetComponent <Image>().sprite = Dodge.GetComponent <Image>().sprite;
                        break;

                    case ChrController.Fav_Defenses.Random:
                        BattleIcon.GetComponent <Image>().sprite = Defrandom.GetComponent <Image>().sprite;
                        break;
                    }
                }
                else if (CombatManager.Instance._isDefensiveBattle == true)
                {
                    if (CombatManager.Instance._isBattleSelectPhase == false)
                    {
                        BattleIconText.text = "";
                        BattleIcon.SetActive(false);
                        return;
                    }
                    BattleIcon.SetActive(true);
                    Power.SetActive(false);
                    Precision.SetActive(false);
                    Technique.SetActive(false);
                    Atkrandom.SetActive(false);
                    Block.SetActive(false);
                    Counter.SetActive(false);
                    Dodge.SetActive(false);
                    Defrandom.SetActive(false);
                    BattleIconText.text = "Favorite\nOffense";
                    switch (curchr._Fav_Offensive)
                    {
                    case ChrController.Fav_Offensives.Power:
                        BattleIcon.GetComponent <Image>().sprite = Power.GetComponent <Image>().sprite;
                        break;

                    case ChrController.Fav_Offensives.Precision:
                        BattleIcon.GetComponent <Image>().sprite = Precision.GetComponent <Image>().sprite;
                        break;

                    case ChrController.Fav_Offensives.Technical:
                        BattleIcon.GetComponent <Image>().sprite = Technique.GetComponent <Image>().sprite;
                        break;

                    case ChrController.Fav_Offensives.Random:
                        BattleIcon.GetComponent <Image>().sprite = Atkrandom.GetComponent <Image>().sprite;
                        break;
                    }
                }
                else
                {
                    BattleIcon.SetActive(false);
                    BattleIconText.text = "Favorite\nTactics";
                    switch (curchr._Fav_Offensive)
                    {
                    case ChrController.Fav_Offensives.Power:
                        Power.SetActive(true);
                        Precision.SetActive(false);
                        Technique.SetActive(false);
                        Atkrandom.SetActive(false);
                        break;

                    case ChrController.Fav_Offensives.Precision:
                        Power.SetActive(false);
                        Precision.SetActive(true);
                        Technique.SetActive(false);
                        Atkrandom.SetActive(false);
                        break;

                    case ChrController.Fav_Offensives.Technical:
                        Power.SetActive(false);
                        Precision.SetActive(false);
                        Technique.SetActive(true);
                        Atkrandom.SetActive(false);
                        break;

                    case ChrController.Fav_Offensives.Random:
                        Power.SetActive(false);
                        Precision.SetActive(false);
                        Technique.SetActive(false);
                        Atkrandom.SetActive(true);
                        break;
                    }
                    switch (curchr._Fav_Defense)
                    {
                    case ChrController.Fav_Defenses.Guard:
                        Block.SetActive(true);
                        Counter.SetActive(false);
                        Dodge.SetActive(false);
                        Defrandom.SetActive(false);
                        break;

                    case ChrController.Fav_Defenses.Counter:
                        Block.SetActive(false);
                        Counter.SetActive(true);
                        Dodge.SetActive(false);
                        Defrandom.SetActive(false);
                        break;

                    case ChrController.Fav_Defenses.Dodge:
                        Block.SetActive(false);
                        Counter.SetActive(false);
                        Dodge.SetActive(true);
                        Defrandom.SetActive(false);
                        break;

                    case ChrController.Fav_Defenses.Random:
                        Block.SetActive(false);
                        Counter.SetActive(false);
                        Dodge.SetActive(false);
                        Defrandom.SetActive(true);
                        break;
                    }
                }
            }
            else
            {
                WholeUI.SetActive(false);
            }
        }
    }
コード例 #29
0
 public CombatFriend()
 {
     _chr   = null;
     _name  = "";
     _image = null;
 }
コード例 #30
0
 public CombatFriend(ChrController chr, string newName, Sprite newImage)
 {
     _chr   = chr;
     _name  = newName;
     _image = newImage;
 }