Beispiel #1
0
    void Update()
    {
        Vector3 currentPlayerPos = player.transform.position;

        StartCoroutine(SantaroCoroutineManager.DelayMethod(
                           tracePlayerDelay, () => playerPosDelayed = currentPlayerPos));
    }
Beispiel #2
0
    public void InputPlayerName()
    {
        if (this.playerNameInputField.text.Replace(" ", "").Replace(" ", "") == "")
        {
            return;
        }
        Debug.Log("入力した名前: " + this.playerNameInputField.text);

        SEManager.Instance.Play(SEPath.DECISION, volumeRate: 0.6f);

        //tokenがある場合、名前だけ変える
        if (PlayerPrefs.HasKey("AccountToken"))
        {
            StartCoroutine(this.networkManager.UpdatePlayerName(this.playerNameInputField.text, PlayerPrefs.GetString("AccountToken"), () =>
            {
                PlayerPrefs.SetString("PlayerName", this.playerNameInputField.text);
                this.changeNameAnnounceText.SetActive(true);
                StartCoroutine(SantaroCoroutineManager.DelayMethod(2f, () => this.changeNameAnnounceText.SetActive(false)));
            }));
        }
        else
        {
            //サーバーにアカウントを作成。名前をthis.playerNameInputField.textに
            StartCoroutine(this.networkManager.RegistAccountFirst(this.playerNameInputField.text, (s) =>
            {
                PlayerPrefs.SetString("PlayerName", this.playerNameInputField.text);
                PlayerPrefs.SetString("AccountToken", s);
                this.changeNameAnnounceText.SetActive(true);
                StartCoroutine(SantaroCoroutineManager.DelayMethod(2f, () => this.changeNameAnnounceText.SetActive(false)));
            }));
        }
    }
Beispiel #3
0
    /// <summary>
    /// プレイヤーが名前を入力したときの処理。アカウント登録していないとき用。非同期処理だとおもうので、voidではなく、IEnumerator等で、コルーチンを利用することになりそう。
    /// </summary>
    public void InputPlayerName()
    {
        if (this.inputPlayerName || this.playerNameInputField.text.Replace(" ", "").Replace(" ", "") == "")
        {
            return;
        }
        this.inputPlayerName = true;
        Debug.Log("入力した名前: " + this.playerNameInputField.text);

        //tokenがある場合、名前だけ変える
        if (this.createdAccount || PlayerPrefs.HasKey("AccountToken"))
        {
            StartCoroutine(this.networkManager.UpdatePlayerName(this.playerNameInputField.text, PlayerPrefs.GetString("AccountToken"), () =>
            {
                PlayerPrefs.SetString("PlayerName", this.playerNameInputField.text);
                StartCoroutine(SantaroCoroutineManager.DelayMethod(1, () => this.OnLogin()));
            }));
        }
        else
        {
            //サーバーにアカウントを作成。名前をthis.playerNameInputField.textに
            StartCoroutine(this.networkManager.RegistAccountFirst(this.playerNameInputField.text, (s) =>
            {
                PlayerPrefs.SetString("PlayerName", this.playerNameInputField.text);
                PlayerPrefs.SetString("AccountToken", s);
                StartCoroutine(SantaroCoroutineManager.DelayMethod(1, () => this.OnLogin()));
            }));
        }
    }
Beispiel #4
0
    public void Attack(Movement movement, Action onFinish)
    {
        if (!this.canSlash)
        {
            return;
        }
        this.canSlash     = false;
        _collider.enabled = true;
        Vector3    defaultLocalSwordPosition = this.swordObject.transform.localPosition;
        Quaternion defaultLocalSwordRotation = this.swordObject.transform.localRotation;

        if (movement.currentBodyDirection == Movement.BodyDirection.Right)
        {
            this.swordObject.transform.localPosition = this.initSwordLocalPositionInRight;
            StartCoroutine(SantaroTransformManager.RotateInCertainTimeByAxisFromAway(this.swordObject.transform, this.playerObject.transform, -120f, this.oneSlashTime, () => {
                onFinish.Invoke();
                this.swordObject.transform.localPosition = defaultLocalSwordPosition;
                this.swordObject.transform.localRotation = defaultLocalSwordRotation;
            }));
            StartCoroutine(SantaroCoroutineManager.DelayMethod(this.oneSlashTime, () => _collider.enabled = false));
            StartCoroutine(SantaroCoroutineManager.DelayMethod(this.oneSlashTime + this.intervalFromFinishSlash, () => this.canSlash = true));
        }
        else
        {
            this.swordObject.transform.localPosition = new Vector3(-this.initSwordLocalPositionInRight.x, this.initSwordLocalPositionInRight.y, 0f);
            StartCoroutine(SantaroTransformManager.RotateInCertainTimeByAxisFromAway(this.swordObject.transform, this.playerObject.transform, 120f, this.oneSlashTime, () => {
                onFinish.Invoke();
                this.swordObject.transform.localPosition = defaultLocalSwordPosition;
                this.swordObject.transform.localRotation = defaultLocalSwordRotation;
            }));
            StartCoroutine(SantaroCoroutineManager.DelayMethod(this.oneSlashTime, () => _collider.enabled = false));
            StartCoroutine(SantaroCoroutineManager.DelayMethod(this.oneSlashTime + this.intervalFromFinishSlash, () => this.canSlash = true));
        }
    }
Beispiel #5
0
    void Update()
    {
        time += Time.deltaTime;
        if (time < 0.5f)
        {
            return;
        }

        Vector3 currentPlayerPos = PlayerCharacter.Instance.transform.position;

        StartCoroutine(SantaroCoroutineManager.DelayMethod(tracePlayerDelay, () => delayedPlayerPos = currentPlayerPos));

        if (transform.position.x + stopThreshold < delayedPlayerPos.x)
        {
            rigidbody.velocity = new Vector2(moveSpeed, rigidbody.velocity.y);
        }
        else if (transform.position.x - stopThreshold > delayedPlayerPos.x)
        {
            rigidbody.velocity = new Vector2(-moveSpeed, rigidbody.velocity.y);
        }
        else
        {
            rigidbody.velocity = new Vector2(0, rigidbody.velocity.y);
        }

        if (rigidbody.velocity.y < -speedYMax)
        {
            rigidbody.velocity = new Vector2(rigidbody.velocity.x, -speedYMax);
        }
        if (rigidbody.velocity.y > speedYMax)
        {
            rigidbody.velocity = new Vector2(rigidbody.velocity.x, speedYMax);
        }
    }
Beispiel #6
0
 private void Update()
 {
     _rigidbody.velocity = new Vector3(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"), 0f).normalized *this.moveSpeed;
     if (this.canAcceleration && (Input.GetKeyDown(KeyCode.K) || Input.GetKeyDown(KeyCode.C)))
     {
         this.moveSpeed      *= 3f;
         this.canAcceleration = false;
         SEManager.Instance.Play(SEPath.SPEED_UP, 0.5f);
         StartCoroutine(SantaroCoroutineManager.DelayMethod(0.3f, () => this.moveSpeed    /= 3f));
         StartCoroutine(SantaroCoroutineManager.DelayMethod(1f, () => this.canAcceleration = true));
     }
 }
Beispiel #7
0
 public void UpdatePlayerName()
 {
     if (this.inputPlayerName)
     {
         return;
     }
     this.inputPlayerName = true;
     Debug.Log("入力した名前: " + this.playerNameInputField.text);
     //サーバーにアカウントを作成。名前をthis.playerNameInputField.textに
     StartCoroutine(this.networkManager.UpdatePlayerName(this.playerNameInputField.text, PlayerPrefs.GetString("AccountToken"), () =>
     {
         PlayerPrefs.SetString("PlayerName", this.playerNameInputField.text);
         StartCoroutine(SantaroCoroutineManager.DelayMethod(1, () => this.OnLogin()));
     }));
 }
Beispiel #8
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("AttackOfPlayer"))
        {
            DamageToHPObject attacker = other.GetComponent <DamageToHPObject>();
            this.currentHp -= attacker.DamageValue;
            attacker.OnAttack();
            SEManager.Instance.Play(SEPath.EXPLOSION_MISSILE, 0.2f);
            this._meshRenderer.material = this.onDamageMaterial;
            StartCoroutine(SantaroCoroutineManager.DelayMethod(0.2f, () => this._meshRenderer.material = this.defaultMaterial));
            //Instantiate(this.damageEffect, this.transform.position, Quaternion.identity);
            if (this.currentHp <= 0)
            {
                this.OnHPLessThanZero();
            }
        }
        if (this.canDamageByEnemyAttack && other.CompareTag("AttackOfEnemy"))
        {
            DamageToHPObject attacker = other.GetComponent <DamageToHPObject>();
            if (attacker != null)
            {
                this.currentHp -= attacker.DamageValue;
                ObjectPoolManager.Instance.InstantiateGameObject(this.damageEffect, this.transform.position, Quaternion.identity);
                attacker.OnAttack();
                if (this.currentHp <= 0)
                {
                    this.OnHPLessThanZero();
                }
            }
        }

        //ホッケーの球が当たった時
        if (other.CompareTag("HockeyBall"))
        {
            //ホッケーの球には必ずDamageToHPObjectをアタッチすること!
            DamageToHPObject attacker = other.GetComponent <DamageToHPObject>();
            this.currentHp -= attacker.DamageValue;
            SEManager.Instance.Play(SEPath.EXPLOSION_MISSILE, 0.2f);
            this._meshRenderer.material = this.onDamageMaterial;
            StartCoroutine(SantaroCoroutineManager.DelayMethod(0.2f, () => this._meshRenderer.material = this.defaultMaterial));
            //Instantiate(this.damageEffect, this.transform.position, Quaternion.identity);
            if (this.currentHp <= 0)
            {
                this.OnHPLessThanZero();
            }
        }
    }
Beispiel #9
0
    public void Attack(Movement movement, Action onFinish)
    {
        if (!this.canThrowLasso)
        {
            return;
        }
        this.canThrowLasso = false;
        StartCoroutine(SantaroCoroutineManager.DelayMethod(this.throwInterval, () => this.canThrowLasso = true));

        if (movement.currentBodyDirection == Movement.BodyDirection.Left)
        {
            GameObject lasso = Instantiate(this.lassoObject, this.leftLassoInstantiatePosition.position, Quaternion.identity);
            lasso.GetComponent <Rigidbody2D>().AddForce(Quaternion.Euler(0f, 0f, this.throwAngle) * Vector2.up * this.throwPower, ForceMode2D.Impulse);
        }
        else
        {
            GameObject lasso = Instantiate(this.lassoObject, this.rightLassoInstantiatePosition.position, Quaternion.identity);
            lasso.GetComponent <Rigidbody2D>().AddForce(Quaternion.Euler(0f, 0f, -this.throwAngle) * Vector2.up * this.throwPower, ForceMode2D.Impulse);
        }
        onFinish.Invoke();
    }
Beispiel #10
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("HockeyBall"))
     {
         if (this.isPlayerGoal)
         {
             this.lampLighting.BloomLightingOn(false);
             StartCoroutine(SantaroCoroutineManager.DelayMethod(this.lightingTimeOnGoal, () => this.lampLighting.BloomLightingOff()));
             Debug.Log("Player側のゴールにシュゥウウウ!!!超エキサイティン!!!");
             SEManager.Instance.Play(SEPath.GOAL_TO_PLAYER, volumeRate: 0.7f);
             PlayerDamageController.Instance.Damaged();
         }
         else
         {
             this.damageToAllEnemyInGoal.enabled = true;
             StartCoroutine(SantaroCoroutineManager.DelayMethod(0.3f, () => this.damageToAllEnemyInGoal.enabled = false));
             this.lampLighting.BloomLightingOn(true);
             StartCoroutine(SantaroCoroutineManager.DelayMethod(this.lightingTimeOnGoal, () => this.lampLighting.BloomLightingOff()));
             Debug.Log("Enemy側のゴールにシュゥウウウ!!!超エキサイティン!!!");
             SEManager.Instance.Play(SEPath.GOAL_TO_ENEMY, volumeRate: 0.8f);
             if (StageManager.Instance != null)
             {
                 StageManager.Instance.CurrentCountGoalHockeyToEnemy++;
                 Debug.Log("現在のゴール数: " + StageManager.Instance.CurrentCountGoalHockeyToEnemy);
             }
         }
         if (UnityEngine.Random.Range(0, 2) == 0)
         {
             other.GetComponent <Rigidbody>().velocity = new Vector3(-3f, -3f, 0f);
             other.transform.root.transform.position   = new Vector3(0f, 9f, 0f);
         }
         else
         {
             other.GetComponent <Rigidbody>().velocity = new Vector3(-3f, 3f, 0f);
             other.transform.root.transform.position   = new Vector3(0f, -9f, 0f);
         }
     }
 }
Beispiel #11
0
 private void OnEnable()
 {
     StartCoroutine(SantaroCoroutineManager.DelayMethod(1, () => this._button.Select()));
 }
Beispiel #12
0
    private void Awake()
    {
        _button = GetComponent <Button>();

        EventTrigger eventTrigger = GetComponent <EventTrigger>();

        if (eventTrigger == null)
        {
            eventTrigger = this.gameObject.AddComponent <EventTrigger>();
        }
        EventTrigger.Entry entry = new EventTrigger.Entry();
        //entry.eventID = EventTriggerType.;
        entry.callback = new EventTrigger.TriggerEvent();
        entry.callback.AddListener((eventData) => { _button.enabled = false; StartCoroutine(SantaroCoroutineManager.DelayMethod(1, () => _button.enabled = true)); });
        eventTrigger.triggers.Add(entry);
    }