Exemple #1
0
        public void Init()
        {
            this.ColliderSupporter = new Collider2DSupporter();

            this.Go       = this.gameObject;
            this.Trans    = this.transform;
            this.Animator = GetComponent <RiaSpriteAnimator>();

            this.SetActive(false);
        }
        public RiaBullet(GameObject _go, RiaCharacterScript _script, PlayerNumber _playerNumber) : base(_go, _script, _playerNumber)
        {
            // CharacterScriptの上書き
            this.Script = _script as RiaBulletScript;

            // キャッシュと初期化
            this.colliderSupporter = this.Actor.ColliderSupporter;
            this.animator          = this.Actor.Animator;

            // パラメータ
            /// 体力
            this.HitPoint = this.Script.HitPointMax;

            /// 画面外処理
            this.areaLeftLine = (this.PlayerNumber == PlayerNumber.player1) ?
                                PlayableArea.pl1AreaLeftLine :
                                PlayableArea.pl2AreaLeftLine;
            this.areaRightLine = (this.PlayerNumber == PlayerNumber.player1) ?
                                 PlayableArea.pl1AreaRightLine :
                                 PlayableArea.pl2AreaRightLine;

            // タグ
            this.playerTag = (this.PlayerNumber == PlayerNumber.player1) ?
                             TagEnum.Player1.ToDescription() :
                             TagEnum.Player2.ToDescription();
            this.playerBulletTag = (this.PlayerNumber == PlayerNumber.player1) ?
                                   TagEnum.PlayerBullet1.ToDescription() :
                                   TagEnum.PlayerBullet2.ToDescription();
            this.enemyTag = (this.PlayerNumber == PlayerNumber.player1) ?
                            TagEnum.Enemy1.ToDescription() :
                            TagEnum.Enemy2.ToDescription();
            this.enemyBulletTag = (this.PlayerNumber == PlayerNumber.player1) ?
                                  TagEnum.EnemyBullet1.ToDescription() :
                                  TagEnum.EnemyBullet2.ToDescription();

            // collider
            this.Actor.GetComponent <CapsuleCollider2D>().size = this.Script.ColliderSize;
        }
        public RiaPlayer(GameObject _go, RiaCharacterScript _script, PlayerNumber _playerNumber) : base(_go, _script, _playerNumber)
        {
            // CharacterScriptの上書き
            this.Script = _script as RiaPlayerScript;

            // キャッシュ
            this.spRender        = this.Go.GetComponent <SpriteRenderer>();
            this.spRender.sprite = this.Script.Sprite;

            this.colliderSupporter = this.Actor.ColliderSupporter;

            this.circleCollider        = this.Go.GetComponent <CircleCollider2D>();
            this.circleCollider.radius = this.Script.CircleColliderRadius;
            this.animator = this.Actor.Animator;
            RiaSpriteAnimation[] anims =
            {
                GameObject.Instantiate <RiaSpriteAnimation>(this.Script.WaitAnimation),
                GameObject.Instantiate <RiaSpriteAnimation>(this.Script.RightGoAnimation),
                GameObject.Instantiate <RiaSpriteAnimation>(this.Script.LeftGoAnimation),
            };
            this.animator.SetAnimations(anims, this.Script.WaitAnimation.KeyName);

            this.bulletManger = null;

            this.rivalPlayer = null;

            // パラメータ
            /// 体力系
            this.HitPoint = this.Script.HitPointMax;

            /// 移動速度系
            this.MoveSpeedDebuffRate = 1.0f;

            /// タグ
            this.enemyTag = (this.PlayerNumber == PlayerNumber.player1) ?
                            TagEnum.Enemy1.ToDescription() :
                            TagEnum.Enemy2.ToDescription();
            this.enemyBulletTag = (this.PlayerNumber == PlayerNumber.player1) ?
                                  TagEnum.EnemyBullet1.ToDescription() :
                                  TagEnum.EnemyBullet2.ToDescription();

            /// 画面外処理
            this.areaLeftLine = (this.PlayerNumber == PlayerNumber.player1) ?
                                PlayableArea.pl1AreaLeftLine :
                                PlayableArea.pl2AreaLeftLine;
            this.areaRightLine = (this.PlayerNumber == PlayerNumber.player1) ?
                                 PlayableArea.pl1AreaRightLine :
                                 PlayableArea.pl2AreaRightLine;

            /// 無敵
            this.invincibleElapsedTime      = 0;
            this.invincibleBlinkingWaitTime = 0;
            this.sprCore         = this.Trans.GetChild(0).GetComponent <SpriteRenderer>();
            this.SpriteAlpha     = 1;
            this.CoreSpriteAlpha = 1;

            /// フレームレートとフレーム時間の算出 by flanny
            var frameRate = (float)Application.targetFrameRate;

            if (frameRate < 0)
            {
                frameRate = (QualitySettings.vSyncCount == 2) ? 30f : 60f;
            }
            var frameTime = 1.0f / frameRate;

            /// 次のコマへ進めるまでの待ち時間の設定 by flanny
            this.invincibleBlinkingWaitTimeMax =
                frameTime * this.Script.InvincibleBlinkingUpdateFrame;
        }
 private void Start()
 {
     this.animator = GetComponent <RiaSpriteAnimator>();
     this.animator.Init(this.animator.Animations.First().KeyName);
 }