예제 #1
0
 void FixedUpdate()
 {
     if (Input.touchCount > 0)
     {
         Vector3    vTmp = new Vector3(Input.GetTouch(0).position.x, Input.GetTouch(0).position.y);
         Ray        ray  = CamMgr.GetInst().GetMainCameraComponent().ScreenPointToRay(vTmp);
         RaycastHit castHit;
         if (Physics.Raycast(ray, out castHit, Mathf.Infinity))
         {
             if (castHit.transform.position == transform.position)
             {
                 if (!StageMgr.Inst.IsPlay)
                 {
                     return;
                 }
                 if (Time.timeScale == 0.0f)
                 {
                     return;
                 }
                 UnitBase PlayerUnit = UnitMgr.Inst.Player;
                 UnitMgr.Inst.MoveUnit(PlayerUnit, PlayerUnit.GetCurPanel(), this);
             }
         }
     }
 }
예제 #2
0
 public static void InitInst()
 {
     if (mInst == null)
     {
         mInst = new CamMgr();
     }
 }
예제 #3
0
    // Use this for initialization
    protected void Start()
    {
        DBMgr.GetInst().OpenConnection();

        m_audioBgm.enabled = false;

        MapMgr.Inst.Initialize();
        MapMgr.Inst.CreateMap();

        CamMgr.GetInst().Initialize();
        ObjectPool.GetInst().Initialzie();
        EffectMgr.GetInst().Initailzie();
        ElementMgr.GetInst().Initialize();
        ChipMgr.Inst.Initialize();
        UnitMgr.Inst.Initialize();

        EffectMgr.GetInst().SetEffectPooled();
        ObjectPool.GetInst().CreatePool();

        if (MultyManager.Inst == null)
        {
            StartCoroutine(UnitMgr.Inst.GenUnit());
            UnitMgr.Inst.EnemyPlay();
        }
    }
예제 #4
0
 public void Clear()
 {
     //反注册事件
     clearFightState(true);
     ZEventSystem.DeRegister(EventConst.OnFightUnitDie, this);
     ZEventSystem.DeRegister(EventConst.OnFightStateChange, this);
     ZEventSystem.DeRegister(EventConst.OnUnitMoveOver, this);
     ZEventSystem.DeRegister(EventConst.OnRequestUnitPause, this);
     ZEventSystem.DeRegister(EventConst.OnFightMaskOver, this);
     ZEventSystem.DeRegister(EventConst.OnGamePause, this);
     ProcessCtrl.Instance.RemoveUpdate(this);
     Fighters.Clear();
     EnemyFighters.Clear();
     AllFighters.Clear();
     if (aStarFinder != null)
     {
         aStarFinder.Clear();
     }
     if (BulletMgrObj != null)
     {
         BulletMgrObj.Clear();
     }
     MapMgr.Instance.Clear();
     EffectMgr.Instance.Clear();
     DropMgrObj     = null;
     CamMgrObj      = null;
     Time.timeScale = 1;
     IsAutoFight    = false;
     UID            = 0;
 }
예제 #5
0
    // Use this for initialization
    void Start()
    {
        GameObject cameraManager = GameObject.Find("Main Camera");

        cameraMgr = cameraManager.AddComponent <CamMgr>();

        // 타겟 카메라를 로컬로 지정
        cameraMgr.replaceTarget(localPlayer);
    }
예제 #6
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        // 충돌된 위치 저장
        collPos = transform.position;

        // 충돌된 위치에서 이펙트 프리팹 생성
        Object obj = Instantiate(expEffect, collPos, Quaternion.identity);

        // 0.1초 후 이펙트 제거
        Destroy(obj, 0.1f);

        // 반경 1.0f 안에 있는 collider2d 추출
        Collider2D[] colls = Physics2D.OverlapCircleAll(collPos, 1.0f);
        foreach (Collider2D findcoll in colls)
        {
            // 태그가 player일 경우
            if (findcoll.gameObject.tag == "Player" || findcoll.gameObject.tag == "NetPlayer")
            {
                playerPos = findcoll.gameObject.transform.position;
                Debug.Log("!!" + findcoll.gameObject.transform.position);
                Debug.Log("collPos = " + collPos);

                // 데미지 계산
                fVec           = collPos - playerPos;
                player_damaged = Mathf.Sqrt(fVec.x * fVec.x + fVec.y * fVec.y + fVec.z + fVec.z) * 100.0f;
                Debug.Log("Damaged:" + player_damaged);

                // 해당 방향으로 밀려난다
                findcoll.attachedRigidbody.mass = 1.0f;
                findcoll.attachedRigidbody.AddForce((playerPos - collPos) * 1000.0f);
            }

            // 반지름을 1로 설정했으므로 그냥 곱하면된다   로컬플레이어만 데미지를 받아 중복계산을 방지한다.
            if (findcoll.gameObject.tag == "Player")
            {
                findcoll.GetComponent <PlayerCtrl>().hp -= (damage - player_damaged);

                // hp를 패킷으로 브로드 캐스트한다.
                GameObject.Find("basket").GetComponent <CharacterRoot>().SendHitPointData(GlobalParam.get().global_account_id, findcoll.GetComponent <PlayerCtrl>().hp);
            }
        }

        // 타겟 카메라를 로컬로 지정
        GameObject cameraManager = GameObject.Find("Main Camera");
        GameObject localPlayer   = GameObject.Find("basket").GetComponent <GameRoot>().GetLocalPlayer();

        camPlayer = localPlayer.GetComponent <FireCtrl>().IsCamPlayer();
        if (!camPlayer)
        {
            cameraMgr = cameraManager.GetComponent <CamMgr>();
            cameraMgr.replaceTarget(localPlayer);
        }
        // 총알 제거
        DestroyObject(gameObject);
    }
예제 #7
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        // 충돌된 위치 저장
        collPos = transform.position;

        // 충돌된 위치에서 이펙트 프리팹 생성
        Object obj = Instantiate(expEffect,collPos,Quaternion.identity);
        // 0.1초 후 이펙트 제거
        Destroy (obj,0.1f);

        // 반경 1.0f 안에 있는 collider2d 추출
        Collider2D[] colls = Physics2D.OverlapCircleAll (collPos, 1.0f);
        foreach (Collider2D findcoll in colls) {
            // 태그가 player일 경우
            if(findcoll.gameObject.tag == "Player" || findcoll.gameObject.tag == "NetPlayer"){
                playerPos = findcoll.gameObject.transform.position;
                Debug.Log ("!!"+findcoll.gameObject.transform.position);
                Debug.Log ("collPos = "+collPos);

                // 데미지 계산
                fVec = collPos - playerPos;
                player_damaged = Mathf.Sqrt(fVec.x * fVec.x + fVec.y * fVec.y + fVec.z + fVec.z) * 100.0f;
                Debug.Log("Damaged:" + player_damaged);

                // 해당 방향으로 밀려난다
                findcoll.attachedRigidbody.mass = 1.0f;
                findcoll.attachedRigidbody.AddForce((playerPos - collPos)*1000.0f);
            }

            // 반지름을 1로 설정했으므로 그냥 곱하면된다   로컬플레이어만 데미지를 받아 중복계산을 방지한다.
            if (findcoll.gameObject.tag == "Player")
            {
                findcoll.GetComponent<PlayerCtrl>().hp -= (damage - player_damaged);

                // hp를 패킷으로 브로드 캐스트한다.
                GameObject.Find("basket").GetComponent<CharacterRoot>().SendHitPointData(GlobalParam.get().global_account_id, findcoll.GetComponent<PlayerCtrl>().hp);

            }
        }

        // 타겟 카메라를 로컬로 지정
        GameObject cameraManager = GameObject.Find("Main Camera");
        GameObject localPlayer = GameObject.Find("basket").GetComponent<GameRoot>().GetLocalPlayer();
        camPlayer = localPlayer.GetComponent<FireCtrl>().IsCamPlayer();
        if (!camPlayer)
        {
            cameraMgr = cameraManager.GetComponent<CamMgr>();
            cameraMgr.replaceTarget(localPlayer);
        }
        // 총알 제거
        DestroyObject (gameObject);
    }
    protected void DamageFunc(int nDamage)
    {
        m_status.nCurHp -= nDamage;
        m_fChargeTime    = 0.0f;
        m_bCharged       = false;
        StopCoroutine(AttackCorutine());
        StopCoroutine(CamMgr.GetInst().SubCamActive(this.transform));
        StopCoroutine(UseChipCoroutine(0));

        CamMgr.GetInst().GetSubCam().SetActive(false);
        if (m_goChip != null)
        {
            ObjectPool.GetInst().PooledObject(m_goChip);
            m_goChip = null;
        }
    }
예제 #9
0
    protected void Awake()
    {
        if (m_inst != null)
        {
            Destroy(gameObject);
            return;
        }

        m_inst = this;

        DBMgr.InitInst();
        MapMgr.InitInst();
        UnitMgr.InitInst();
        EffectMgr.InitInst();
        ElementMgr.InitInst();
        ChipMgr.InitInst();
        ObjectPool.InitInst();
        CamMgr.InitInst();

        m_audioBgm        = transform.GetComponent <AudioSource> ();
        m_clipDeleteEnemy = Resources.Load <AudioClip> ("Sound/Bgm/EnemyDeleted");
        m_clipGameover    = Resources.Load <AudioClip> ("Sound/Bgm/Gameover");
    }
 protected virtual void UseSubCam()
 {
     StartCoroutine(CamMgr.GetInst().SubCamActive(transform));
 }
예제 #11
0
    // Use this for initialization
    void Start()
    {
        GameObject cameraManager = GameObject.Find("Main Camera");
        cameraMgr = cameraManager.AddComponent<CamMgr>();

        // 타겟 카메라를 로컬로 지정
        cameraMgr.replaceTarget(localPlayer);
    }
예제 #12
0
    // Update is called once per frame
    void Update()
    {
        //if (UIMgr.OnClickFireButton ()) {
        //	Fire();
        //}

        fireBar = GameObject.Find("FirePos").GetComponent <LineRenderer>();

        // 2초로 파워 제한
        timer += Time.deltaTime;
        if (timer > MAX_TIMER)
        {
            timer = MAX_TIMER;
        }
        if (coolTimer >= 0)
        {
            coolTimer -= Time.deltaTime;
        }

        if (Input.anyKeyDown)
        {
            camPlayer = true;
        }


        if (coolTimer <= 0)
        {
            // 발사힘 결정
            if (Input.GetMouseButtonDown(0))
            {
                shotEnable = true;
                timer      = 0.0f;
            }

            if (shotEnable)
            {
                // Fire 바 표시
                fireBar.SetPosition(1, new Vector3(1.0f * (timer / MAX_TIMER), 0.0f, 0.0f));
                fireBar.SetWidth(0.0f, 0.2f * (timer / MAX_TIMER));

                if (Input.GetMouseButtonUp(0))
                {
                    // 파워 저장
                    shotTimer = timer;
                    Fire();

                    // 초기화 작업
                    coolTimer  = 3.0f;
                    shotEnable = false;
                    camPlayer  = false;
                    fireBar.SetPosition(1, new Vector3(0.0f, 0.0f, 0.0f));
                    fireBar.SetWidth(0.0f, 0.0f);
                }
            }
        }

        GameObject cameraManager = GameObject.Find("Main Camera");
        GameObject localPlayer   = GameObject.Find("basket").GetComponent <GameRoot>().GetLocalPlayer();

        cameraMgr = cameraManager.GetComponent <CamMgr>();
        if (!camPlayer)
        {
            // 타겟 카메라를 발사체로 지정
            if (target_projectile != null)
            {
                cameraMgr.replaceTarget(target_projectile);
            }
        }
        else
        {
            cameraMgr.replaceTarget(localPlayer);
        }
    }
예제 #13
0
    // Update is called once per frame
    void Update()
    {
        //if (UIMgr.OnClickFireButton ()) {
        //	Fire();
        //}

        fireBar = GameObject.Find("FirePos").GetComponent<LineRenderer>();

        // 2초로 파워 제한
        timer += Time.deltaTime;
        if (timer > MAX_TIMER) { timer = MAX_TIMER; }
        if (coolTimer >= 0) { coolTimer -= Time.deltaTime; }

        if (Input.anyKeyDown)
        {
            camPlayer = true;
        }

        if (coolTimer <= 0)
        {
            // 발사힘 결정
            if (Input.GetMouseButtonDown(0))
            {
                shotEnable = true;
                timer = 0.0f;
            }

            if (shotEnable)
            {
                // Fire 바 표시
                fireBar.SetPosition(1, new Vector3(1.0f * (timer / MAX_TIMER), 0.0f, 0.0f));
                fireBar.SetWidth(0.0f, 0.2f * (timer / MAX_TIMER));

                if (Input.GetMouseButtonUp(0))
                {
                    // 파워 저장
                    shotTimer = timer;
                    Fire();

                    // 초기화 작업
                    coolTimer = 3.0f;
                    shotEnable = false;
                    camPlayer = false;
                    fireBar.SetPosition(1, new Vector3(0.0f, 0.0f, 0.0f));
                    fireBar.SetWidth(0.0f, 0.0f);
                }
            }
        }

        GameObject cameraManager = GameObject.Find("Main Camera");
        GameObject localPlayer = GameObject.Find("basket").GetComponent<GameRoot>().GetLocalPlayer();
        cameraMgr = cameraManager.GetComponent<CamMgr>();
        if (!camPlayer)
        {
            // 타겟 카메라를 발사체로 지정
            if (target_projectile != null)
            {
                cameraMgr.replaceTarget(target_projectile);
            }
        }
        else
        {
            cameraMgr.replaceTarget(localPlayer);
        }
    }
예제 #14
0
        protected virtual void Awake()
        {
            Time.timeScale = 1.0f; //unfreeze game if it was frozen from a previous game.

            Initialized = false;   //faction stats are not ready, yet

            //Get components:
            CamMgr           = FindObjectOfType(typeof(CameraController)) as CameraController; //Find the camera movement script.
            ResourceMgr      = FindObjectOfType(typeof(ResourceManager)) as ResourceManager;   //Find the resource manager script.
            BuildingMgr      = FindObjectOfType(typeof(BuildingManager)) as BuildingManager;
            TaskMgr          = FindObjectOfType(typeof(TaskManager)) as TaskManager;
            UnitMgr          = FindObjectOfType(typeof(UnitManager)) as UnitManager;
            SelectionMgr     = FindObjectOfType(typeof(SelectionManager)) as SelectionManager;
            GroupSelection   = FindObjectOfType(typeof(UnitGroupSelection)) as UnitGroupSelection;
            PlacementMgr     = FindObjectOfType(typeof(BuildingPlacement)) as BuildingPlacement;
            TerrainMgr       = FindObjectOfType(typeof(TerrainManager)) as TerrainManager;
            MvtMgr           = FindObjectOfType(typeof(MovementManager)) as MovementManager;
            UIMgr            = FindObjectOfType(typeof(UIManager)) as UIManager; //Find the UI manager script.
            ErrorMessageMgr  = FindObjectOfType(typeof(ErrorMessageHandler)) as ErrorMessageHandler;
            MinimapIconMgr   = FindObjectOfType(typeof(MinimapIconManager)) as MinimapIconManager;
            AttackWarningMgr = FindObjectOfType(typeof(AttackWarningManager)) as AttackWarningManager;
            AttackMgr        = FindObjectOfType(typeof(AttackManager)) as AttackManager;
            EffectPool       = FindObjectOfType(typeof(EffectObjPool)) as EffectObjPool;
            UpgradeMgr       = FindObjectOfType(typeof(UpgradeManager)) as UpgradeManager;
            InputMgr         = FindObjectOfType(typeof(InputManager)) as InputManager;
#if RTSENGINE_FOW
            FoWMgr = FindObjectOfType(typeof(FogOfWarRTSManager)) as FogOfWarRTSManager;
#endif

#if RTSENGINE_FOW
            if (FoWMgr) //only if there's a fog of war manager in the scene
            {
                FoWMgr.Init(this);
            }
#endif

            CamMgr.Init(this);
            MinimapIconMgr?.Init(this);
            MvtMgr.Init(this);
            TaskMgr.Init(this);
            SelectionMgr.Init(this);
            GroupSelection.Init(this);
            PlacementMgr.Init(this);
            TerrainMgr.Init(this);
            UIMgr.Init(this); //initialize the UI manager.
            ErrorMessageMgr.Init(this);
            AttackWarningMgr?.Init(this);
            AttackMgr.Init(this);
            EffectPool.Init(this);
            UpgradeMgr.Init(this);
            ResourceMgr.Init(this);
            BuildingMgr.Init(this);
            UnitMgr.Init(this);
            InputMgr.Init(this);

            MultiplayerGame = false;                               //We start by assuming it's a single player game.

            if (!InitMultiplayerGame() && !InitSinglePlayerGame()) //if it's not neither a multiplayer nor a single player game
            {
                InitFactions();                                    //we're starting the game directly from the editor in the map scene, init factions directly
            }

            ResourceMgr.InitFactionResources();       //init resources for factions.

            InitCampaignGame();                       //initialise a game where the player is coming from the campaign menu to play a mission
            SetPlayerFaction();                       //pick the player faction ID.
            InitDefaultEntities();                    //initialise the pre-spawned faction units and factions

            ResourceMgr.InitResources();              //init the pre-spawned resources.

            UnitMgr.OnFactionSlotsInitialized();      //init free units
            BuildingMgr.OnFactionSlotsInitialized();  //init free buildings
            if (MultiplayerGame)                      //if this is a multiplayer game
            {
                InputMgr.OnFactionSlotsInitialized(); //init spawnable prefabs and default entities in a multiplayer game
            }
            //In order to avoid having buildings that are being placed by AI players and units collide, we will ignore physics between their two layers:
            Physics.IgnoreLayerCollision(LayerMask.NameToLayer("Hidden"), LayerMask.NameToLayer("Unit"));

            //Set the amount of the active factions:
            activefactionsAmount = factions.Count;

            SetGameState(GameState.running);          //the game state is now set to running

            UIMgr.PeaceTime.Toggle(peaceTime > 0.0f); //enable the peace time panel if there's actual peace time assigned

            //reaching this point means that all faction info/stats in the game manager are ready:
            Initialized = true;
        }
예제 #15
0
    /// <summary>
    /// 开始一场战斗
    /// </summary>
    /// <param name="isPvp">比赛性质,pve还是pvp</param>
    /// <param name="treasures">宝箱数量</param>
    public void CreateFight(bool isPvp, int treasures = 0)
    {
        this.State = FightState.Init;
        if (this.Fighters == null)
        {
            EDebug.LogError("FightLogic.CreateFight failed, fighters is null");
            return;
        }
        if (this.EnemyFighters == null)
        {
            EDebug.LogError("FightLogic.CreateFight failed, fighters is null");
            return;
        }
        if (this.Fighters.Count == 0)
        {
            EDebug.LogError("FightLogic.CreateFight failed, fighters is empty");
            return;
        }
        if (this.EnemyFighters.Count == 0)
        {
            EDebug.LogError("FightLogic.CreateFight failed, enemyFighters is empty");
            return;
        }

        this.TotalRound = this.EnemyFighters.Count;
        this.CurRound   = 0;
        this.IsPvp      = isPvp;
        this.Treasures  = treasures;
        this.DropMgrObj = new DropMgr();
        aStarFinder     = new AStarFinder(PathFinder.V_GRID, (this.TotalRound * 3 + 1) * PathFinder.H_GRID);

        List <FightUnit> allUnit = new List <FightUnit>();

        for (int idx = 0; idx < Fighters.Count; ++idx)
        {
            allUnit.Add(Fighters[idx]);
        }
        for (int idx = 0; idx < EnemyFighters.Count; ++idx)
        {
            for (int idx2 = 0; idx2 < EnemyFighters[idx].Count; ++idx2)
            {
                allUnit.Add(EnemyFighters[idx][idx2]);
            }
        }

        for (int idx = 0; idx < allUnit.Count; ++idx)
        {
            allUnit[idx].UID = ++UID;
        }
        ZEventSystem.Dispatch(EventConst.OnCreateFight, allUnit);

        //Test~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        for (int idx = 0; idx < Fighters.Count; ++idx)
        {
            FightUnit unit = Fighters[idx];
            _createFightUnitView(unit);
        }

        MapMgr.Instance.CreateFightMap(1, TotalRound);
        CamMgrObj = GameObject.Find("Main Camera").GetComponent <CamMgr>();

        //EndTest~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        //注册事件
        ZEventSystem.Register(EventConst.OnFightUnitDie, this, "OnUnitDie");
        ZEventSystem.Register(EventConst.OnFightStateChange, this, "OnFightStateChange");
        ZEventSystem.Register(EventConst.OnRequestUnitPause, this, "OnRequestUnitPause");
        ZEventSystem.Register(EventConst.OnFightMaskOver, this, "OnFightMaskOver");
        ZEventSystem.Register(EventConst.OnGamePause, this, "OnGamePause");

        //CamMgrObj.StartDissolve();
        CamMgrObj.PlayStartEffect();
        NextRound();
        ProcessCtrl.Instance.AddUpdate(this);
    }