예제 #1
0
    protected virtual void Update()
    {
        timer += Time.deltaTime;

        if (Input.GetKeyDown(KeyCode.R))
        {
            isReloading = true;
        }

        if (!isReloading)
        {
            if (Input.GetMouseButton(0) && (Time.timeScale != 0))
            {
                animator.SetBool("onFire", true);
                LogicEventListener.Invoke(eEventType.FOR_PLAYER, eEventMessage.ON_SHOT_FIRED);
                if (timer >= timeBetweenBullets)
                {
                    Fire();
                }
            }
            else
            {
                animator.SetBool("onFire", false);
            }

            if (timer >= timeBetweenBullets * effectDisplayTime)
            {
                DisableEffects();
            }
        }
        else
        {
            Reload();
        }
    }
예제 #2
0
    void Skill_RapidFire()
    {
        // 애니메이터 전환
        animator.SetTrigger("Skill_Rapid");

        // 총 오브젝트 제거
        // ... Update에서 처리

        // 스킬 효과 적용
        for (int i = 0; i < EfxParticles.Length; i++)
        {
            EfxParticles[i].Play();
        }

        GameObject[] Players = GameObject.FindGameObjectsWithTag("Player");

        for (int i = 0; i < Players.Length; i++)
        {
            Weapon[] weapons = Players[i].GetComponentsInChildren <Weapon>();
            for (int j = 0; j < weapons.Length; j++)
            {
                weapons[j].CurrentBullet += 100;
                LogicEventListener.Invoke(eEventType.FOR_UI, eEventMessage.ON_AMMUNITION_COUNT_CHANGED, CurrentBullet, weapons[j].MaxBullet);
            }
        }
    }
예제 #3
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape) && false == IsMenuOpened)
        {
            IsMenuOpened = true;
            SwitchMenuUI(true);
            LogicEventListener.Invoke(eEventType.FOR_SYSTEM, eEventMessage.ON_MENU_OPENED);
        }
        else
        if (Input.GetKeyDown(KeyCode.Escape) && true == IsMenuOpened)
        {
            IsMenuOpened = false;
            SwitchMenuUI(false);
            LogicEventListener.Invoke(eEventType.FOR_SYSTEM, eEventMessage.ON_MENU_CLOSED);
        }

        if (Input.GetKeyDown(KeyCode.T) && false == IsChatUIOpened)
        {
            IsChatUIOpened = true;
            SwitchChatUI(true);
            LogicEventListener.Invoke(eEventType.FOR_SYSTEM, eEventMessage.ON_CHAT_UI_OPENED);
        }
        else
        if (Input.GetKeyDown(KeyCode.T) && true == IsChatUIOpened)
        {
            IsChatUIOpened = false;
            SwitchChatUI(true);
            LogicEventListener.Invoke(eEventType.FOR_SYSTEM, eEventMessage.ON_CHAT_UI_CLOSED);
        }
    }
예제 #4
0
    protected virtual void Fire()
    {
        // 타이머 초기화
        timer = 0f;

        CurrentBullet -= 1;

        ShootRay = Camera.main.ScreenPointToRay(ScreenCenter);

        // 각종 이펙트 재생
        GunSound.Play();
        //GunParticle.Stop(); // 파티클은 멈추고 시작해주는 작업 필요.
        //GunParticle.Play();
        for (int i = 0; i < objFireEfx.Length; i++)
        {
            objFireEfx[i].SetActive(true);
        }
        LogicEventListener.Invoke(eEventType.FOR_UI, eEventMessage.ON_AMMUNITION_COUNT_CHANGED, CurrentBullet, MaxBullet);

        // RayCast
        if (Physics.Raycast(ShootRay, out ShootHit, range, shootableMask))
        {
            var objHealth = ShootHit.collider.gameObject.GetComponent <Health>();
            objHealth.TakeDamage(1);
        }
    }
예제 #5
0
    public virtual void TakeDamage(int amount)
    {
        damaged = true;


        currentHealth -= amount;

        Dbg.Log($"{currentHealth}");
        if (IsPlayer)
        {
            float healthPointRatio = currentHealth /*/ startingHealth * 100.0f*/;
            LogicEventListener.Invoke(eEventType.FOR_UI, eEventMessage.ON_HEALTH_POINT_CHANGED, (object)healthPointRatio);
        }

        // TODO: 플레이어 아닐떄에만 폭발사
        if (currentHealth <= 0 && !isDead && !IsPlayer)
        {
            if (objDeadEffect != null)
            {
                Instantiate(objDeadEffect, transform.position, transform.rotation);
            }

            Death();
        }
    }
예제 #6
0
    void Start()
    {
        GameObject player = default;

        if (Utils.IsNull(PlayerSync.LocalPlayerInst))
        {
            player      = PhotonNetwork.Instantiate("Player", new Vector3(0.0f, 50.0f, 150.0f), Quaternion.identity);
            player.name = "LocalPlayer";
            LogicEventListener.Invoke(eEventType.FOR_ALL, eEventMessage.ON_LOCAL_PLAYER_CREATED, player);
        }

        // Preload all the required scenes for the stage1.
        //AsyncOperation[] additionalSceneStatus = new AsyncOperation[2]{
        //    SceneManager.LoadSceneAsync("ChatUI", LoadSceneMode.Additive),
        //    SceneManager.LoadSceneAsync("MenuUI", LoadSceneMode.Additive)
        //};

        SceneManager.LoadScene("ChatUI", LoadSceneMode.Additive);
        SceneManager.LoadScene("MenuUI", LoadSceneMode.Additive);

        Scenes[0] = SceneManager.GetSceneAt(1);
        Scenes[1] = SceneManager.GetSceneAt(2);

        // GetRootGameObjects works properly after the scene has been fully loaded!
        StartCoroutine(Yielder.GetCoroutine(() =>
        {
            Scenes[0].GetRootGameObjects(ChatSceneGOs);
            SwitchChatUI(false);

            Scenes[1].GetRootGameObjects(MenuSceneGOs);
            SwitchMenuUI(false);
        }, 0.25f));
    }
예제 #7
0
 public void ViewWeapon()
 {
     for (int i = 0; i < HideObjects.Length; i++)
     {
         HideObjects[i].SetActive(true);
     }
     LogicEventListener.Invoke(eEventType.FOR_UI, eEventMessage.ON_AMMUNITION_COUNT_CHANGED, CurrentBullet, MaxBullet);
 }
예제 #8
0
    protected virtual void Fire(float _reboundParam = 1.0f)
    {
        // 타이머 초기화
        timer = 0f;

        if (CurrentBullet < 1)
        {
            return;
        }

        LogicEventListener.Invoke(eEventType.FOR_PLAYER, eEventMessage.ON_SHOT_FIRED);
        IsFiring = true;

        CurrentBullet -= 1;

        // 카메라 뷰포트 중심 좌표 기준으로 사격 Ray 생성
        ShootRay = Camera.main.ScreenPointToRay(ScreenCenter);

        // 각종 이펙트 재생
        GunSound.Play();
        for (int i = 0; i < objFireEfx.Length; i++)
        {
            objFireEfx[i].SetActive(true);
        }
        animator.gameObject.GetComponent <NewController>().ShootRebound(_reboundParam);

        LogicEventListener.Invoke(eEventType.FOR_UI, eEventMessage.ON_AMMUNITION_COUNT_CHANGED, CurrentBullet, MaxBullet);


        // RayCast
        if (IsEnemyHit = Physics.Raycast(ShootRay, out ShootHit, range, shootableMask))
        {
            objHitEfx.SetActive(true);
            EnemyHitPoint = ShootHit.point;
            objHitEfx.transform.position = ShootHit.point;
            // 플레이어를 쐈을 때 스킵
            if (ShootHit.collider.tag == "Player")
            {
                return;
            }

            // 체력 속성이 있다면 데미지 가한다
            var objHealth = ShootHit.collider.gameObject.GetComponent <Health>();
            if (objHealth)
            {
                objHealth.TakeDamage(damagePerShot);
            }

            // 지뢰 속성이 있다면 밀치기 시킨다
            Mine mine = ShootHit.collider.GetComponent <Mine>();
            if (mine)
            {
                // 지뢰 밀치기
                mine.HitReaction(ShootRay.direction);
            }
        }
    }
예제 #9
0
 void OnCloseMenuClicked()
 {
     if (false == IsCloseMenuClicked)
     {
         Dbg.Log("Menu is closed");
         IsCloseMenuClicked = true;
         LogicEventListener.Invoke(eEventType.FOR_SYSTEM, eEventMessage.ON_MENU_CLOSED);
     }
 }
예제 #10
0
    protected override void Update()
    {
        if (photonView.IsMine || !AppManager.Instance().isOnline)
        {
            timer += Time.deltaTime;

            if (Input.GetMouseButton(0) && (Time.timeScale != 0))
            {
                if (timer >= timeBetweenBullets)
                {
                    ReboundDir = -playerCamera.transform.forward; // 밀림 방향 결정
                    Fire();
                }
            }
            else
            {
                animator.SetBool("onFire", false);
            }

            if (timer >= timeBetweenBullets * effectDisplayTime)
            {
                DisableEffects();
            }

            // UI + 카메라 전환
            if (UiTimer > UiSwitchDelay)
            {
                playerCamera.mode = NewTPSCamera.Mode.SNIPING;
                SnipingImg.color  = new Color(SnipingImg.color.r, SnipingImg.color.g, SnipingImg.color.b, 1.0f);
                LogicEventListener.Invoke(eEventType.FOR_UI, eEventMessage.ON_AMMUNITION_COUNT_CHANGED, CurrentBullet, MaxBullet);
            }

            // 뒤로 밀림 효과. 플레이어 컨트롤러와 같은 감쇄공식 적용.
            NowRebounding = NowRebounding - (NowRebounding * Deceleration * Time.deltaTime);
            playerTransform.Translate(NowRebounding, Space.World);

            if (Input.GetKeyDown(KeyCode.Q) && WeaponSwitchTimer > WeaponSwitchDelay)
            {
                // 애니메이터 전환
                animator.SetBool("isSniping", false);

                // 무기 교체
                SwitchWeapons();
            }
            // 타이머 진행
            WeaponSwitchTimer += Time.deltaTime;
            UiTimer           += Time.deltaTime;
        }
        else
        {
            FireFx();
        }
    }
예제 #11
0
    IEnumerator LaunchMissileThread()
    {
        float[] dists = new float[3];
        int     len   = LeftFireTransform.Length;

        for (int i = 0; i < len; i++)
        {
            Transform res         = default;
            float     minDist     = 0.0f;
            var       leftMissile = Instantiate(objMissile, LeftFireTransform[i].position, LeftFireTransform[i].rotation);
            for (int j = 0; j < PlayerTfList.Count; ++j)
            {
                dists[j] = (leftMissile.transform.position - PlayerTfList[j].position).magnitude;
            }

            for (int k = 0; k < PlayerTfList.Count; ++k)
            {
                if (dists[k] > minDist)
                {
                    minDist = dists[k];
                    res     = PlayerTfList[k];
                }
            }

            leftMissile.GetComponent <Missile>().Target = res;

            LogicEventListener.Invoke(eEventType.FOR_ALL, eEventMessage.ON_MISSILE_SPAWNED, LeftFireTransform[i]);

            var rightMissile = Instantiate(objMissile, RightFireTransform[i].position, RightFireTransform[i].rotation);
            for (int j = 0; j < PlayerTfList.Count; ++j)
            {
                dists[j] = (rightMissile.transform.position - PlayerTfList[j].position).magnitude;
            }

            for (int k = 0; k < PlayerTfList.Count; ++k)
            {
                if (dists[k] > minDist)
                {
                    minDist = dists[k];
                    res     = PlayerTfList[k];
                }
            }

            rightMissile.GetComponent <Missile>().Target = res;

            LogicEventListener.Invoke(eEventType.FOR_ALL, eEventMessage.ON_MISSILE_SPAWNED, RightFireTransform[i]);
            yield return(new WaitForSeconds(0.3f));
        }

        yield break;
    }
    IEnumerator _ScreenFill()
    {
        float alpha = Image.color.a;

        IsMovingNextScene = false;
        while (alpha <= 1.0f && false == IsMovingNextScene)
        {
            alpha      += AlphaIncrease * Time.deltaTime;
            Image.color = new Color(Image.color.r, Image.color.g, Image.color.b, alpha);
            yield return(Yielder.GetCoroutine(0.03f));
        }
        IsMovingNextScene = true;
        LogicEventListener.Invoke(eEventType.FOR_SYSTEM, eEventMessage.FADER_FULLY_APPEARED);
    }
예제 #13
0
    //void LaunchMissle()
    //{
    //    for (int i = 0; i < MissileFireTransform.Length; i++)
    //        Instantiate(objMissile, MissileFireTransform[i].position, MissileFireTransform[i].rotation);
    //    bLaunchComplete = true;
    //}

    IEnumerator LaunchMissileThread()
    {
        for (int i = 0; i < LeftFireTransform.Length; i++)
        {
            Dbg.Log($"Missiles launched! count :{ LeftFireTransform.Length.ToString()}", this);
            Instantiate(objMissile, LeftFireTransform[i].position, LeftFireTransform[i].rotation);
            LogicEventListener.Invoke(eEventType.FOR_ALL, eEventMessage.ON_MISSILE_SPAWNED, LeftFireTransform[i], "MISSILE");
            Instantiate(objMissile, RightFireTransform[i].position, RightFireTransform[i].rotation);
            LogicEventListener.Invoke(eEventType.FOR_ALL, eEventMessage.ON_MISSILE_SPAWNED, RightFireTransform[i], "MISSILE");
            yield return(new WaitForSeconds(0.3f));
        }

        yield break;
    }
예제 #14
0
    IEnumerator ReloadingAnimationPlay()
    {
        animator.SetBool("isReloading", true);
        LogicEventListener.Invoke(eEventType.FOR_UI, eEventMessage.ON_AMMUNITION_COUNT_CHANGED, CurrentBullet, MaxBullet);
        float animatorTime = 0f;

        while (animatorTime < Reloadtime)
        {
            animatorTime += Time.deltaTime;
            animator.SetFloat("ReloadTime", animatorTime);
            yield return(null);
        }

        animator.SetBool("isReloading", false);
        animator.SetFloat("ReloadTime", 0f);
        isReloading = false;
        yield break;
    }
예제 #15
0
 /// <summary>
 /// Start the connection.
 /// 연결 시작.
 /// - If already connected, we attempt joining a random room.
 ///   만약 연결되었으면, 랜덤 룸으로 입장 시도.
 /// - If not yet connected, Connect this app instance to Photon Cloud Network.
 ///   연결 되어있지 않으면, 앱인스턴스를 포톤 클라우드 네트워크로 연결.
 /// </summary>
 public void InitializeConnection()
 {
     // Keep track of the will to join a room, because when we come back from the game we will get a callback that we are connected, so we need to know what to do then.
     IsConnecting = true;
     // If we are not connected, initiate the connection to the server.
     if (true == PhotonNetwork.IsConnected)
     {
         // We need to attempt joinging a random room.
         //if it fails we'll get notified in 'OnJoinRandomFailed()' and we'll create new one.
         PhotonNetwork.JoinRandomRoom();
     }
     else
     {
         // We first must connect to Photon online server.
         PhotonNetwork.GameVersion = GameVersion;
         PhotonNetwork.ConnectUsingSettings();
     }
     LogicEventListener.Invoke(eEventType.FOR_SYSTEM, eEventMessage.ON_CONNECTED);
 }
    IEnumerator _SplashImageAppear()
    {
        float alpha = Image.GetAlpha();

        while (alpha <= 1.0f && false == IsFullyAppeared)
        {
            alpha += AlphaIncrease * Time.deltaTime;
            Image.SetAlpha(alpha);
            yield return(Yielder.GetCoroutine(0.05f));
        }

        LogicEventListener.Invoke(eEventType.FOR_ALL, eEventMessage.SPLASH_FULLY_APPEARED);
        // 한번만 실행되도록 보장.
        // Make secured this logic executes once.
        if (false == IsFullyAppeared)
        {
            IsFullyAppeared = true;
        }
    }
예제 #17
0
    IEnumerator _UpdateTimeVariables()
    {
        while (true)
        {
            if (RemainingTime > 0.0f)
            {
                RemainingTime -= 1.0f;
            }
            else
            {
                Dbg.Log($"Remaining Time is zero! Coroutine finished~", this);
                // TODO: change this coroutine repeatedly turns on and off.
                break;
            }

            ElapsedTime += 1.0f;
            float timeLeftRatio = RemainingTime / InitialRemainingTime;
            LogicEventListener.Invoke(eEventType.FOR_UI, eEventMessage.ON_REMAINING_TIME_CHANGED, (object)timeLeftRatio);
            yield return(Yielder.GetCoroutine(1.0f));
        }
    }
예제 #18
0
    // TakeDamage()는 별도로 선언하지 않으면
    // 묵시적으로 base의 것으로 자동 선언되는 듯 함

    void SlowRecovery()
    {
        CurrentHealth += 1;
        LogicEventListener.Invoke(eEventType.FOR_UI, eEventMessage.ON_HEALTH_POINT_CHANGED, (object)CurrentHealth);
    }
예제 #19
0
 void OnLogin()
 {
     FlyAwayAnims[0].SetTrigger("FlyAway");
     FlyAwayAnims[1].SetTrigger("FlyAway");
     LogicEventListener.Invoke(eEventType.FOR_SYSTEM, eEventMessage.ON_LOGIN_BUTTON_CLICKED);
 }
예제 #20
0
 public override void Explotion()
 {
     LogicEventListener.Invoke(eEventType.FOR_ALL, eEventMessage.ON_MISSILE_EXPLOSION, transform);
     GameObject.Instantiate(objExplotionEfx, gameObject.transform.position, Quaternion.identity);
     base.Explotion();
 }
예제 #21
0
 /// <summary>
 /// Called when the player is leaving from PhotonNetwork Room explicitly. it's used for abstraction.
 /// </summary>
 public virtual void OnLeaveRoom()
 {
     PhotonNetwork.LeaveRoom();
     PhotonNetwork.LoadLevel("Lobby");
     LogicEventListener.Invoke(eEventType.FOR_ALL, eEventMessage.ON_LEAVE_ROOM);
 }
예제 #22
0
 void OnLogin()
 {
     FlyAwayAnims[0].SetTrigger("FlyAway");
     FlyAwayAnims[1].SetTrigger("FlyAway");
     LogicEventListener.Invoke(eEventType.FOR_SYSTEM, eEventMessage.ON_ANYKEY_PRESSED);
 }