Exemplo n.º 1
0
    public override void Skill_2(params object[] param)      //范围箭
    {
        int      inputAngleX        = Convert.ToInt32(param[0]);
        int      inputAngleY        = Convert.ToInt32(param[1]);
        int      PlayAnimationFrame = Convert.ToInt32(param[2]);
        TSVector mTSVector          = new TSVector((FP)inputAngleX / 1000, FP.Zero, (FP)inputAngleY / 1000);
        int      Range = 9;

        WillUsedPrefabs[2].SetActive(true);
        TrueSyncManager.SyncedInstantiate(WillUsedPrefabs[2], new TSVector(AllTSTransform.position.x, 0, AllTSTransform.position.z) + mTSVector * Range, RotateTSTransform.rotation);
        WillUsedPrefabs[2].SetActive(false);

        /***
         * if (PlayAnimationFrame == 0)
         * {
         *      WillUsedPrefabs[2] = _AssetManager.GetGameObject("magical/fx/dark_area_prefab");
         *      TSTransform dark_area_prefab_AllTSTransform = WillUsedPrefabs[2].GetComponent<TSTransform>();
         *      dark_area_prefab_AllTSTransform.position = new TSVector(AllTSTransform.position.x, 0, AllTSTransform.position.z);
         *
         *      dark_area_prefab_AllTSTransform.Translate(mTSVector * Range);
         *      dark_area_prefab_AllTSTransform.OnUpdate();
         * }
         * else {
         *      TSTransform dark_area_prefab_AllTSTransform = WillUsedPrefabs[2].GetComponent<TSTransform>();
         *      int Range = 3;
         *      dark_area_prefab_AllTSTransform.Translate(mTSVector * Range);
         *      dark_area_prefab_AllTSTransform.OnUpdate();
         * }
         ***/
        Debug.LogErrorFormat("Skill_2范围箭==========>{0},{1}", mTSVector, PlayAnimationFrame);
    }
    public void OnSyncedTriggerEnter(TSCollision other)
    {
        int otherLayerMask = (int)Math.Pow(2, other.gameObject.layer);

        Debug.LogErrorFormat("houyiBullet====>Trigger  Enter==>{0},{1},{2}", otherLayerMask, other.gameObject.name, LayerMask.GetMask("Role"));
        if (otherLayerMask == LayerMask.GetMask("Role"))
        {
            Actor mActor = other.gameObject.GetComponent <Actor>();
            Debug.LogErrorFormat("houyiBullet====>TriggerEnter==>自己阵营:{0},对方阵营={1}", OwnerCamp, mActor.OwnerCamp);
            if (OwnerCamp != mActor.OwnerCamp)
            {
                mActor.mActorAttr.Hp -= 10;
                TrueSyncManager.SyncedDestroy(gameObject);
            }
        }
        else if (otherLayerMask == LayerMask.GetMask("Monsters"))
        {
            YeGuaiAI mYeGuaiAI = other.gameObject.GetComponent <YeGuaiAI>();
            mYeGuaiAI.AddHp(-10, OwnerID);
        }
        else if (otherLayerMask == LayerMask.GetMask("GroundWall"))
        {
            TrueSyncManager.SyncedDestroy(gameObject);
        }
    }
Exemplo n.º 3
0
 private void OnHitEnemyActor()
 {
     //Debug.LogErrorFormat("OnHitEnemyActor====>");
     mTargetEnemyActor.AddHp(-3, OwnerID);
     mTargetEnemyActor = null;
     TrueSyncManager.SyncedDestroy(gameObject);
 }
Exemplo n.º 4
0
 private void OnHitEnemyActor()
 {
     //Debug.LogErrorFormat("OnHitEnemyActor====>");
     mTargetEnemyActor.mActorAttr.Hp -= 3;
     mTargetEnemyActor = null;
     TrueSyncManager.SyncedDestroy(gameObject);
 }
Exemplo n.º 5
0
    private void PauseMatch()
    {
        if (m_Paused)
        {
            return;
        }

        Debug.Log("[MatchController] Pause.");

        m_Paused = true;

        // If offline, pause simulation.

        if (PhotonNetwork.offlineMode)
        {
            TrueSyncManager.PauseSimulationMain();
        }

        // Callback.

        OnPauseMatch();

        // Raise event.

        if (m_MatchPausedEvent != null)
        {
            m_MatchPausedEvent();
        }
    }
Exemplo n.º 6
0
    private void UnpauseMatch()
    {
        if (!m_Paused)
        {
            return;
        }

        Debug.Log("[MatchController] Unpause.");

        m_Paused = false;

        // If offline, resume simulation.

        if (PhotonNetwork.offlineMode)
        {
            TrueSyncManager.RunSimulationMain();
        }

        // Callback.

        OnUnpauseMatch();

        // Raise event.

        if (m_MatchUnpausedEvent != null)
        {
            m_MatchUnpausedEvent();
        }
    }
Exemplo n.º 7
0
    void Start()
    {
        _playerList.Add(this);

        this.name    = "player " + _playerList.Count;
        _characterTS = GameObject.Instantiate(PlayerConfig.Instance.CharacterPrefab).transform;

        _characterTS.name = "character player " + _playerList.Count;

        _areaHighlightLayerMask    = 1 << LayerMask.GetMask("PlayerArea");
        _powerupLayerMask          = 1 << LayerMask.GetMask("Powerup");
        _areaHighlightMesh         = new Mesh();
        _areaHighlightMeshCollider = gameObject.AddComponent <MeshCollider>();
        _areaHighlightMeshRenderer = gameObject.AddComponent <MeshRenderer>();
        _areaHighlightMeshFilter   = gameObject.AddComponent <MeshFilter>();

        if (_playerList.Count == 1)
        {
            Line.LineList.Add(TrueSyncManager.SyncedInstantiate(Resources.Load("Prefabs/prefab_Line") as GameObject, TSVector.up, TSQuaternion.identity).GetComponent <TSRigidBody>());
            Line.LineList.Add(TrueSyncManager.SyncedInstantiate(Resources.Load("Prefabs/prefab_Line") as GameObject, TSVector.up, TSQuaternion.identity).GetComponent <TSRigidBody>());
        }
        else if (_playerList.Count > 2)
        {
            Line.LineList.Add(TrueSyncManager.SyncedInstantiate(Resources.Load("Prefabs/prefab_Line") as GameObject, TSVector.up, TSQuaternion.identity).GetComponent <TSRigidBody>());
        }

        if (PositionMarkerGO == null)
        {
            PositionMarkerGO = Resources.Load("Prefabs/prefab_PositionMarker") as GameObject;
        }

        AdjustLineAssignments();
        RepositionLines();
    }
Exemplo n.º 8
0
    public void MatchBecomeInvalid()
    {
        if (!m_MatchValid)
        {
            return;
        }

        m_MatchValid = false;

        // End TrueSync simulation.

        TrueSyncManager.EndSimulationMain();
        m_SimulationEnded = true;

        // Callback.

        OnMatchBecomeInvalid();

        // Raise event.

        if (m_MatchBecomeInvalidEvent != null)
        {
            m_MatchBecomeInvalidEvent();
        }
    }
Exemplo n.º 9
0
    /**
     * @brief Updates ball's movements and instantiates new ball objects when player press space.
     **/
    public override void OnSyncedUpdate()
    {
        FP   hor = (FP)TrueSyncInput.GetInt(INPUT_KEY_HORIZONTAL) / 100;
        FP   ver = (FP)TrueSyncInput.GetInt(INPUT_KEY_VERTICAL) / 100;
        bool currentCreateState = TrueSyncInput.GetInt(INPUT_KEY_CREATE) == 1;

        // Instantiates a new ball belonging to current player if the following criteria is true
        if (!lastCreateState && currentCreateState && !createdRuntime)
        {
            SimpleControl otherSP = TrueSyncManager.SyncedInstantiate(prefab, tsTransform.position, tsTransform.rotation).GetComponent <SimpleControl>();
            otherSP.createdRuntime = true;
            otherSP.owner          = owner;

            lastCreateState = currentCreateState;

            return;
        }

        TSVector forceToApply = TSVector.zero;

        if (FP.Abs(hor) > FP.Zero)
        {
            forceToApply.x = hor / 3;
        }

        if (FP.Abs(ver) > FP.Zero)
        {
            forceToApply.z = ver / 3;
        }

        controlledBody.AddForce(forceToApply, ForceMode.Impulse);

        lastCreateState = currentCreateState;
    }
Exemplo n.º 10
0
    public override void Skill_3(params object[] param)      //远程箭
    {
        int      inputAngleX = Convert.ToInt32(param[0]);
        int      inputAngleY = Convert.ToInt32(param[1]);
        TSVector mTSVector;

        if (inputAngleX == 0 && inputAngleY == 0)
        {
            mTSVector = new TSVector(Angle.x, FP.Zero, Angle.z);
        }
        else
        {
            mTSVector = new TSVector((FP)inputAngleX / 1000, FP.Zero, (FP)inputAngleY / 1000);
        }
        //houyiBullet houyibullethouyiBullet = WillUsedPrefabs[1].GetComponent<houyiBullet>();
        //houyibullethouyiBullet.ownerIndex = (int)Id;
        //houyibullethouyiBullet.AllTSTransform.position = new TSVector(AllTSTransform.position.x, 1, AllTSTransform.position.z);
        //houyibullethouyiBullet.RotateTSTransform.rotation = TSQuaternion.LookRotation(mTSVector);
        //houyibullethouyiBullet.Angle = mTSVector;
        Debug.LogErrorFormat("Skill_3远程箭==========>{0},{1},{2},OwnerID={3}", inputAngleX, inputAngleY, mTSVector, OwnerID);
        GameObject realObj = TrueSyncManager.SyncedInstantiate(WillUsedPrefabs[1], new TSVector(AllTSTransform.position.x, 1, AllTSTransform.position.z), TSQuaternion.identity);

        realObj.SetActive(true);
        houyiBullet houyibullethouyiBullet2 = realObj.GetComponent <houyiBullet>();

        houyibullethouyiBullet2.RotateTSTransform.rotation = TSQuaternion.LookRotation(mTSVector);
        houyibullethouyiBullet2.Angle = mTSVector;
    }
Exemplo n.º 11
0
 // Update is called once per frame
 public override void OnSyncedUpdate()
 {
     if (SpawnGuy)
     {
         SpawnGuy = false;
         TrueSyncManager.SyncedStartCoroutine(SpawnTimer());
     }
 }
Exemplo n.º 12
0
 private void Awake()
 {
     tsManager = GetComponent <TrueSyncManager>();
     if (tsManager == null)
     {
         LogUtil.Error("没有 TrueSyncManager");
     }
 }
Exemplo n.º 13
0
 public override void OnSyncedUpdate()
 {
     SelfTick += 1;
     if (SelfTick >= 100)
     {
         TrueSyncManager.SyncedDestroy(gameObject);
     }
 }
Exemplo n.º 14
0
 public override void OnSyncedUpdate()
 {
     if (IsDead)
     {
         // 如果已死亡/损毁,同步销毁本对象
         TrueSyncManager.SyncedDestroy(this.gameObject);
     }
 }
Exemplo n.º 15
0
 public void OnSyncedTriggerEnter(TSCollision other)
 {
     if (other.gameObject.tag != "Coin")
     {
         return;
     }
     TrueSyncManager.SyncedDestroy(other.gameObject);
 }
Exemplo n.º 16
0
 public override void OnSyncedUpdate()
 {
     if (destroyTime <= 0)
     {
         TrueSyncManager.SyncedDestroy(this.gameObject);
     }
     tsTransform.Translate(direction * speed * TrueSyncManager.DeltaTime);
     destroyTime -= TrueSyncManager.DeltaTime;
 }
Exemplo n.º 17
0
    void Fire()
    {
        canFire = false;

        TrueSyncManager.SyncedStartCoroutine(FireCoolDown());

        TSVector   position = new TSVector(transform.GetChild(0).position.x, transform.GetChild(0).position.y, transform.GetChild(0).position.z);
        GameObject bullet   = TrueSyncManager.SyncedInstantiate(bulletPrefab, position, tsTransform.rotation);
    }
Exemplo n.º 18
0
    public override void Skill_4(params object[] param)      //普攻箭
    {
        Actor      mTargetActor           = param[0] as Actor;
        GameObject houyibasebullet_prefab = TrueSyncManager.SyncedInstantiate(WillUsedPrefabs[3], new TSVector(AllTSTransform.position.x, 0, AllTSTransform.position.z), TSQuaternion.identity);

        houyibasebullet_prefab.SetActive(true);
        houyiBaseBullet mYeGuaiBaseBullet = houyibasebullet_prefab.GetComponent <houyiBaseBullet>();

        mYeGuaiBaseBullet.mTargetEnemyActor = mTargetActor;
        Debug.LogErrorFormat("Skill_4普攻箭==========>OwnerID={0},TargetOwnerID={1}", OwnerID, mTargetActor.OwnerID);
    }
Exemplo n.º 19
0
    public void SpawnBadGuy()
    {
        TrueSyncManager.SyncedInstantiate(BadGuy, Spawns [spawnID].GetComponent <TSTransform> ().position, TSQuaternion.identity);

        spawnID++;

        if (spawnID > Spawns.Length - 1)
        {
            spawnID = 0;
        }
    }
Exemplo n.º 20
0
 public void OnSyncedTriggerEnter(TSCollision other)
 {
     if (other.gameObject.tag == "Player")
     {
         PlayerMovement hitPlayer = other.gameObject.GetComponent <PlayerMovement>();
         if (hitPlayer.owner != owner)
         {
             TrueSyncManager.SyncedDestroy(this.gameObject);
             hitPlayer.Respawn();
         }
     }
 }
Exemplo n.º 21
0
 public void OnSyncedTriggerEnter(TSCollision other)
 {
     if (other.gameObject.tag != "Coin")
     {
         return;
     }
     foreach (var player in GameObject.FindGameObjectsWithTag("Player"))
     {
         player.GetComponent <CoinSpawner>().Coin++;
     }
     TrueSyncManager.SyncedDestroy(other.gameObject);
 }
Exemplo n.º 22
0
 /**
  * @brief Instantiates and places all boxes required by {@link #numberOfBoxesX} and {@link #numberOfBoxesZ}.
  **/
 void CreateBoxes()
 {
     for (int i = 0; i < numberOfBoxesX; i++)
     {
         for (int j = 0; j < numberOfBoxesZ; j++)
         {
             GameObject  box  = TrueSyncManager.SyncedInstantiate(this.boxPrefab, TSVector.zero, TSQuaternion.identity);
             TSRigidBody body = box.GetComponent <TSRigidBody>();
             body.position = new TrueSync.TSVector(i * 2 - 5, 1, j * 2);
         }
     }
 }
Exemplo n.º 23
0
    // Create a unit of a type at the left or right flank
    private void CreateUnit(int type, int positionCode)
    {
        TSVector   position;
        GameObject prefab;
        int        attack = 1, hp = 1;
        FP         range = 0f;


        switch (type)
        {
        case 1:         // Melee Unit
            prefab = this.unitPrefab;
            attack = 10;
            hp     = 30;
            range  = 0f;
            break;

        case 2:         // Ranged Unit
            prefab = this.unit2Prefab;
            attack = 5;
            hp     = 20;
            range  = 3f;
            break;

        default:
            Debug.Log("Incorrect type specified by CreateUnit");
            return;
        }
        UnitData stats = new UnitData(hp, attack, range);


        switch (positionCode)
        {
        case 1:         // Left flank
            position = leftSpawn;
            break;

        case 2:         // Right flank
            position = rightSpawn;
            break;

        default:
            Debug.Log("Incorrect positionCode specified by CreateUnit");
            return;
        }

        position.x *= positionFactor;
        position.z *= positionFactor;
        UnitBehavior unitBehavior = TrueSyncManager.SyncedInstantiate(prefab, position, TSQuaternion.identity).GetComponent <UnitBehavior>();

        unitBehavior.owner = owner;
        unitBehavior.SetData(stats);
    }
Exemplo n.º 24
0
    /// <summary>
    /// OnTapLocation - call this to handle distributing and processing taps across a synchronized network game session
    /// Responds to taps and decides what to do
    /// </summary>
    /// <param name="tapLocation">location where tap/click took place</param>
    private void OnTapLocation(TSVector tapLocation)
    {
        // Handle powerup taps
        GameObject tlsc = TrueSyncManager.SyncedInstantiate(Resources.Load("Prefabs/TapLocationSphereCheck") as GameObject, tapLocation, TSQuaternion.identity);

        tlsc.GetComponent <TapLocationSphereCheck>().Owner = localOwner;

        // Find any status effect that may have been tapped
        FP           shortestDistance = 1000;
        StatusEffect nearestSe        = null;

        foreach (StatusEffect se in StatusEffectSystem.spawnedStatusEffects)
        {
            FP dist = TSVector.Distance(se.tsTransform.position, tapLocation);
            if (dist <= se.GetComponent <TSSphereCollider>().radius&& dist < shortestDistance)
            {
                shortestDistance = dist;
                nearestSe        = se;
            }
        }
        if (nearestSe != null) // Found a status effect to handle
        {
            return;            // exit this method to handle status effect within its own framework
        }
        // Shows where click took place (position marker):
        GameObject positionMarker = TrueSyncManager.SyncedInstantiate(PositionMarkerGO, tapLocation, TSQuaternion.identity);

        positionMarker.transform.position = tapLocation.ToVector();
        positionMarker.name = "Position Marker";    // Identify this marker game object in unity editor

        TSTransform tst = positionMarker.GetComponent <TSTransform>();

        tst.scale = TSVector.one * PlayerConfig.Instance.MinTapDistance;
        Renderer rend = positionMarker.GetComponent <Renderer>();

        if (TSVector.Distance(lastValidTapLocation, tapLocation) >= PlayerConfig.Instance.MinTapDistanceFromPrevious)
        {
            TapNearLine(tapLocation);
            rend.material.color = Color.black;
        }
        else
        {
            rend.material.color = Color.red;
        }

        DOTween.ToAlpha(() => rend.material.color, x => rend.material.color = x, 0, 5f).OnComplete(() =>
        {
            TrueSyncManager.Destroy(positionMarker);
        });

        lastValidTapLocation = tapLocation;
    }
Exemplo n.º 25
0
    private void FixedUpdate()
    {
        I++;
        if (I == 500)
        {
            TrueSyncManager.PauseSimulation();

            foreach (var item in tSTransforms)
            {
                Debug.Log(item.position.x + ">>>" + item.position.y + ">>>" + item.position.z);
            }
        }
    }
Exemplo n.º 26
0
    public override void OnSyncedUpdate()
    {
        // Check state
        switch (unitState)
        {
        case UnitState.Walking:
            tsTransform.Translate(translation);
            break;


        case UnitState.Attacking:
            if (attackDelayCurrent <= 0)
            {
                if (target == null)
                {
                    if (!FindNewTarget())
                    {
                        unitState = UnitState.Walking;
                        break;
                    }
                }
                DealDamage(target, unitData.atk);
                attackDelayCurrent = attackDelay;
            }
            else
            {
                attackDelayCurrent -= TrueSyncManager.DeltaTime;
            }
            break;


        case UnitState.Summoning:
            if (summonTime > 0)
            {
                summonTime -= TrueSyncManager.DeltaTime;
            }
            else
            {
                unitState = UnitState.Walking;
            }
            break;
        }

        // Update health and kill object if necessary
        textMesh.text = "HP: " + unitData.currentHp + " / " + unitData.totalHp;

        if (unitData.currentHp <= 0)
        {
            TrueSyncManager.SyncedDestroy(gameObject);
        }
    }
Exemplo n.º 27
0
    public override void OnSyncedUpdate()
    {
        base.OnSyncedUpdate();

        if (!m_RunSyncedUpdate)
        {
            return;
        }

        // Read delta time.

        FP deltaTime = TrueSyncManager.deltaTimeMain;

        // Update timers.

        UpdateTimers(deltaTime);

        // Handle actions.

        bool buttonDown = TrueSyncInput.HasByte(m_ButtonDownCode);

        if (buttonDown && (m_Timer == FP.Zero))
        {
            int tick = TrueSyncManager.ticksMain;
            if (!m_EffectTicks.Contains(tick))
            {
                if (m_Pivot != null)
                {
                    EffectUtils.PlayEffect(m_Effect, m_Pivot);
                }

                m_EffectTicks.Add(tick);
            }

            m_Timer = m_Cooldown;
        }

        // Clear effect ticks cache.

        for (int index = 0; index < m_EffectTicks.Count; ++index)
        {
            int tick = m_EffectTicks[index];

            if (TrueSyncManager.IsTickOutOfRollbackMain(tick))
            {
                m_EffectTicks.RemoveAt(index);
                index = -1;
            }
        }
    }
Exemplo n.º 28
0
 public void OnSyncedCollisionEnter(TSCollision other)
 {
     if (other.gameObject.CompareTag("Bullet"))
     {
         //Debug.Log ("COLLIDING: " + other.gameObject.name);
         ChangeLife(false, other.gameObject.GetComponent <Bullet> ().Damage);
         TrueSyncManager.SyncedDestroy(other.gameObject);
     }
     if (other.gameObject.CompareTag("BadGuy") && this.gameObject.CompareTag("Player"))
     {
         //Debug.Log ("COLLIDING: " + other.gameObject.name);
         ChangeLife(false, 5);
     }
 }
Exemplo n.º 29
0
    // INTERNALS

    private void CreatePlayerInputCollector()
    {
        GameObject             playerInputCollectorGo = new GameObject("PlayerInputCollector");
        tnPlayerInputCollector playerInputCollector   = playerInputCollectorGo.AddComponent <tnPlayerInputCollector>();

        TrueSyncObject trueSyncObject  = playerInputCollectorGo.AddComponent <TrueSyncObject>();
        TSPlayerInfo   localPlayerInfo = TrueSyncManager.localPlayerMain;
        byte           localPlayerId   = (localPlayerInfo != null) ? localPlayerInfo.Id : (byte)0;

        trueSyncObject.SetOwnerId(localPlayerId);

        TrueSyncManager.RegisterTrueSyncObjectMain(trueSyncObject);

        m_PlayerInputCollector = playerInputCollector;
    }
Exemplo n.º 30
0
    public override void OnPlayerDisconnection(int i_PlayerId)
    {
        base.OnPlayerDisconnection(i_PlayerId);

        if (simulationRunning)
        {
            // Callback.

            OnPlayerDisconnected(i_PlayerId);

            // Remove player.

            TrueSyncManager.RemovePlayerMain(i_PlayerId);
        }
    }