/*
 *  public void DebugCapsule(Vector3 start, Vector3 end, float radius) {
 *      debug_capsule.Add(new DebugCapsuleEntity {
 *          enable = true,
 *          position = start,
 *          end = end,
 *          radius = radius,
 *          draw_color_alpha = 1f,
 *          remaining_time = debug_remaining_time_default,
 *      });
 *  }
 */
    public void Hit()
    {
        //Debug.Log("PlayerController.Hit()");

        var check_start_offset = 0.3f;

        var check_max_distance = 1.5f;

        var check_radius = 0.1f;

        RaycastHit rayHit = default(RaycastHit);

        Ray ray = new Ray(
            transform.position +
            new Vector3(0f, 0.5f, 0f) +
            transform.forward * -check_start_offset,
            transform.forward
            );

        int layer_mask = (1 << LayerMask.NameToLayer("Enemy"));
        //int layer_mask = LayerMask.NameToLayer("Enemy");
        bool onhit = false;

        if (enemy_target != null)
        {
            var ec = enemy_target.GetComponent <EnemyController>();
            check_max_distance = ec.attack_distance + check_start_offset;

            //DebugCapsule(check_start, check_end, check_radius);
            //DebugSphere(ray, check_radius, check_max_distance);

            if (Physics.SphereCast(ray, check_radius, out rayHit, check_max_distance, layer_mask))
            {
                Debug.Log("Physics.CheckCapsule hit");
                onhit = true;
            }
            else
            {
                Debug.Log("Physics.SphereCast not hit");
            }
        }

        if (onhit)
        {
            var se_name = SeService.getPlayerAttack(EquipService.rank(), EquipService.type());
            //MessageBroker.Default.Publish<PlaySe>(new PlaySe{ name = se_name });
            PlaySE(se_name);

            rayHit.transform.SendMessage("OnDamage", PlayerService.atk_total());
        }
        else
        {
            // miss
            if (enemy_target != null)
            {
                enemy_target.transform.SendMessage("OnMiss");
            }
        }
    }
    public void OnMainActionEquip(RaycastHit rayHit)
    {
        rayHit.transform.gameObject.SendMessage("OnTarget");
        EquipService.OnTarget(rayHit.collider.gameObject);

        if (enemy_target != null)
        {
            enemy_target.SendMessage("TargetDisable");
            enemy_target = null;
        }
    }
 public void slot1LoadGame()
 {
     loadGame(1, s1go, s1p);
     if (s2go != null)
     {
         EquipService.del(s2p.equip.id);
     }
     if (s3go != null)
     {
         EquipService.del(s3p.equip.id);
     }
 }
Example #4
0
    void Awake()
    {
        EquipFactory.init(prefabs);
        //EquipService.init();

        MessageBroker.Default.Receive <EquipEvent>().Subscribe(x => {
            Debug.Log("MessageBroker.Default.Receive<EquipEvent>().Subscribe()");
            EquipService.onlyEquip(x.id, x.go, x.update_service_data);
        });

        MessageBroker.Default.Receive <ChangeEquipEvent>().Subscribe(x => {
            Debug.Log("MessageBroker.Default.Receive<ChangeEquipEvent>().Subscribe()");
            EquipService.equipChange(x.id, x.go);
            MessageBroker.Default.Publish <SaveDataSave>(new SaveDataSave());
        });
    }
        public static int atk_total()
        {
            int atk = _entity.atk + EquipService.status("AtkTotal");

            return(atk + Mathf.RoundToInt(Random.Range(atk * -0.1f, atk * 0.1f)));

/*
 *          int rand = 0;
 *
 *          while (rand == 0) {
 *              rand = Random.Range(-1, 1);
 *          }
 *
 *          return atk + (Mathf.RoundToInt(Random.Range(atk * 0.01f, atk * 0.09f)) * rand);
 */
        }
    public void slot3LoadGame()
    {
        loadGame(3, s3go, s3p);
        if (s1go != null)
        {
            EquipService.del(s1p.equip.id);
        }
        if (s2go != null)
        {
            EquipService.del(s2p.equip.id);
        }

        // シーン遷移保持データ"スロット3"保存
        // シーン遷移保持データ"キャラデータ"スロット3のキャラデータ保存
        // シーン遷移保持データ"ステージデータ"スロット3のステージデータ保存
        // シーン遷移
        // 遷移先でキャラデータ、ステージデータ展開してからゲーム開始
    }
Example #7
0
    public void applySceneChangeTitle()
    {
        Debug.Log("MessageBroker.Default.Publish<SceneChangeSingle>()");
        Time.timeScale = 0f;

        MessageBroker.Default.Publish <SceneChangeSimple>(new SceneChangeSimple {
            add_scene = "Title",
            del_scene = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name,

            pre_action = () => {
                // GUI表示をタイトル画面に切り替え
                GuiService.modeChange(GuiState.Title);

                // 設定画面表示を消去
                toggle_settings_dialog();

                // NextRoomを消去
                EffectService.nextRoomClear();

                // 地面に落ちてる装備品を削除
                EquipService.ClearTarget();
                EquipService.destroyEquipItem();

                // 装備品リストをクリア
                EquipService.clear();

                // 家具配置範囲再初期化
                EffectiveFloorService.reset();

                // 家具再初期化
                FieldObjectService.clear();

                // 敵削除
                EnemyService.destroyEnemyDead();
                EnemyService.destroyEnemy();
                EnemyService.stopSpawn();
            },

            post_action = () => {
                Time.timeScale = 1f;
            }
        });
    }
    public void OnMainAciton()
    {
        if (this.in_action)
        {
            return;
        }
        this.in_action = true;

        //if (!this.character_control) return;
        if (this.state == State.Dead)
        {
            return;
        }
        //if (!character_control) return;

        //RaycastHit rayHit = new RaycastHit();
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        //Debug.Log("PlayerController.OnMainAciton() : Input.mousePosition: " + Input.mousePosition);

        int layer_mask = (1 << LayerMask.NameToLayer("Default")) | (1 << LayerMask.NameToLayer("ItemEquip")) | (1 << LayerMask.NameToLayer("Enemy"));

        RaycastHit[] hits      = Physics.RaycastAll(ray, 100, layer_mask);
        RaycastHit   enemy_hit = new RaycastHit();
        RaycastHit   item_hit  = new RaycastHit();
        RaycastHit   floor_hit = new RaycastHit();

        foreach (var ray_hit in hits)
        {
            //Debug.Log("PlayerController.OnMainAciton() : ray_hit.point: " + ray_hit.point);
            if (ray_hit.collider == null)
            {
                continue;
            }

            if (ray_hit.transform.tag == "Enemy" && enemy_hit.collider == null)
            {
                enemy_hit = ray_hit;
            }
            else
            if (ray_hit.transform.tag == "ItemEquip" && item_hit.collider == null)
            {
                item_hit = ray_hit;
            }

            if (floor_hit.collider == null)
            {
                floor_hit = ray_hit;
            }
        }

/*
 *      if (5 < enemy_history.Count) {
 *          var max = enemy_history.Count;
 *          for (var count = 5; count < max; count += 1) {
 *              var de = enemy_history.Dequeue();
 *              if (de != null) de.SendMessage("TargetDisable");
 *          }
 *      }
 */
        if (enemy_hit.collider != null)
        {
            if (enemy_target == null || enemy_target != enemy_hit.transform.gameObject)
            {
                //if (enemy_target != null) { enemy_target.SendMessage("TargetDisable"); }
                //enemy_history.Enqueue(enemy_hit.transform.gameObject);
                enemy_target = enemy_hit.transform.gameObject;

                foreach (var obj in GameObject.FindGameObjectsWithTag("Enemy"))
                {
                    if (obj == enemy_target)
                    {
                        obj.SendMessage("OnTarget");
                    }
                    else
                    {
                        obj.SendMessage("TargetDisable");
                    }
                }

                var ec = enemy_target.GetComponent <EnemyController>();
                enemy_target_distance = ec.attack_distance;
                Debug.Log("enemy_target_distance : " + enemy_target_distance);

                enemy_target.SendMessage("OnTarget");

                if (enemy_target_distance < Math.Abs(Vector3.Distance(enemy_target.transform.position, transform.position)))
                {
                    nmAgent.ResetPath();

                    Observable.NextFrame().Subscribe(x => {
                        if (nmAgent == null || !nmAgent.enabled)
                        {
                            return;
                        }
                        nmAgent.SetDestination(enemy_target.transform.position);
                    });

                    AnimationChange("Idle");
                }
            }
            //Debug.Log("new target : " + enemy_target.name);
        }
        else
        if (item_hit.collider != null)
        {
            item_hit.transform.gameObject.SendMessage("OnTarget");
            EquipService.OnTarget(item_hit.collider.gameObject);

            if (enemy_target != null)
            {
                enemy_target.SendMessage("TargetDisable");
                enemy_target = null;
            }
        }
        else
        {
            if (enemy_target != null)
            {
                enemy_target.SendMessage("TargetDisable");
                enemy_target = null;
            }
        }

        if (enemy_hit.collider == null && floor_hit.collider != null)
        {
            nmAgent.ResetPath();

            Observable.NextFrame().Subscribe(x => {
                nmAgent.SetDestination(floor_hit.point + na_destination_offset);
            });

            //animator.radioBool("Idle");
            //AnimationChange("Idle");
        }

        AnimationChange("Dash");
        this.in_action = false;

/*
 *      if (Physics.Raycast(ray, out rayHit, 100, layer_mask)) {
 *          Debug.Log("rayHit.transform.gameObject.layer : " + rayHit.transform.gameObject.layer);
 *          Debug.Log("rayHit.transform.tag : " + rayHit.transform.tag);
 *
 *          if (rayHit.transform.tag == "Enemy") {
 *              enemy_target = rayHit.transform.gameObject;
 *              Debug.Log("new target : " + enemy_target.name);
 *              enemy_target.SendMessage("OnTarget");
 *          } else
 *          if (rayHit.transform.tag == "ItemEquip") {
 *              rayHit.transform.gameObject.SendMessage("OnTarget");
 *              EquipService.OnTarget(rayHit.collider.gameObject);
 *
 *              if (enemy_target != null) {
 *                  enemy_target.SendMessage("TargetDisable");
 *                  enemy_target = null;
 *              }
 *          } else {
 *              if (enemy_target != null) {
 *                  enemy_target.SendMessage("TargetDisable");
 *                  enemy_target = null;
 *              }
 *          }
 *
 *          if (rayHit.collider != null) {
 *              //Debug.Log("rayHit.point: " + rayHit.point);
 *              //nmAgent.destination = rayHit.point;
 *              nmAgent.ResetPath();
 *              nmAgent.SetDestination(rayHit.point + na_destination_offset);
 *              animator.SetBool("DoIdle", false);
 *
 *              //Debug.Log("PlayerController::OnMainAciton() : rayHit.collider.gameObject.name : " + rayHit.collider.gameObject.name);
 *              //Debug.Log("PlayerController::OnMainAciton() : rayHit.collider.gameObject.tag : " + rayHit.collider.gameObject.tag);
 *          }
 *      }
 */
    }
    void OnAttack()
    {
/*
 *      if (!animator.GetBool("DoAttack")) {
 *          animator.SetBool("DoAttack", true);
 *      }
 */

        if (on_attack)
        {
            return;
        }
        on_attack = true;

        character_control = false;

        //Debug.Log("PlayerController.OnIdle()");
        //animator.radioBool("Attack");
        AnimationChange("Attack");
        //animator.SetBool("DoIdle", true);
        animator.Update(0);
        AnimatorClipInfo[] anim_clip_info = animator.GetCurrentAnimatorClipInfo(0);
        //Debug.Log("PlayerController : anim_clip_info[0].clip.length : " + (anim_clip_info[0].clip.length).ToString());

        int spd = PlayerService.spd_total();

        //Debug.Log("PlayerController : spd before : " + spd.ToString());

        spd = (max_attack_speed < spd) ? max_attack_speed : spd;
        spd = (spd < 1) ? 1 : spd;
        //Debug.Log("PlayerController : spd after : " + spd.ToString());

        float attack_spd = (((attack_speed * 1f) - (spd * 1f)) / (attack_speed * 1f)) * EquipService.attack_speed_adjust();

        //Debug.Log("PlayerController : attack_speed : " + attack_speed.ToString());
        //Debug.Log("PlayerController : spd : " + spd.ToString());
        //Debug.Log("PlayerController : (attack_speed - spd) / attack_speed : " + ((attack_speed - spd) / attack_speed).ToString());
        //Debug.Log("PlayerController : attack_spd : " + attack_spd.ToString());

        animator.SetFloat("AttackSpeed", attack_spd);

        //animator.Play("Idle2", 0, 0f);
        //Debug.Log("PlayerController::OnAttack() anim_clip_info[0].clip.length: " + anim_clip_info[0].clip.length.ToString());

        Observable.Timer(TimeSpan.FromSeconds(anim_clip_info[0].clip.length))
        .Subscribe(t => {
            //animator.radioBool("Idle");
            AnimationChange("Idle");
            character_control = true;
            on_attack         = false;
        });
        //.Subscribe(t => animator.SetBool("DoIdle", false));

/*
 *      animator.Play("Attack",
 *          nextFrameAction: () => {
 *              //Debug.Log("再生開始の次フレーム");
 *          },
 *          endAction: () => {
 *              //Debug.Log("アニメーション終了");
 *              animator.radioBool("Idle");
 *              character_control = true;
 *          });
 */
        var voice_name_attack = SeService.getPlayerAttackVoice();

        //MessageBroker.Default.Publish<PlaySe>(new PlaySe{ name = voice_name_attack });
        PlaySE(voice_name_attack);
    }
 public static int spd_total()
 {
     return(_entity.spd + EquipService.status("SpdTotal"));
 }
 public static int def_total()
 {
     return(_entity.def + EquipService.status("DefTotal"));
 }