Пример #1
0
 void Start()
 {
     if (entity == null)
     {
         SyncPosRot syncScript = GetComponent <SyncPosRot>();
         if (syncScript != null)
         {
             entity = syncScript.entity;
         }
     }
 }
Пример #2
0
    public void updateDirection(KBEngine.PropsEntity entity)
    {
        if (entity.renderObj == null)
        {
            return;
        }

        SyncPosRot syncScript = ((GameObject)entity.renderObj).GetComponent <SyncPosRot>();

        syncScript.syncEuler = entity.eulerAngles;
        syncScript.spaceID   = KBEngineApp.app.spaceID;
    }
Пример #3
0
    public void set_direction(KBEngine.PropsEntity entity)
    {
        if (entity.renderObj == null)
        {
            return;
        }

        SyncPosRot syncScript = ((GameObject)entity.renderObj).GetComponent <SyncPosRot>();

        syncScript.RealSyncRotation(entity);
        syncScript.spaceID = KBEngineApp.app.spaceID;
    }
Пример #4
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject != master)
     {
         if (other.gameObject.tag == "nonLocalPlayer" &&
             master.gameObject.tag == "localPlayer")
         {
             SyncPosRot     syncScript = gameObject.GetComponent <SyncPosRot>();
             KBEngine.Arrow kbeArrow   = syncScript.entity as KBEngine.Arrow;
             CombatProps    cp         = other.gameObject.GetComponent <CombatProps>();
             if (cp != null)
             {
                 cp.addDamage((AttackType)kbeArrow.attackType, damage);
             }
         }
         Safe_Destroy();
     }
 }
Пример #5
0
    private void OnCollisionEnter(Collision collision)
    {
        SyncPosRot script = collision.collider.gameObject.GetComponent <SyncPosRot>();

        if (script != null)
        {
            KBEngine.Entity player = KBEngine.KBEngineApp.app.player();
            if (script.entity != null && player != null)
            {
                if (script.entity.id == player.id)
                {
                    if ((Int32)entity.getDefinedProperty("controllId") != player.id)
                    {
                        entity.cellCall("reqControll", new object[] { player.id });
                    }
                }
            }
        }
    }
Пример #6
0
    void waitRangeFire(WeaponType shotType)
    {
        //calculate count
        int parallelCount = 1;

        switch (shotType)
        {
        case WeaponType.WEAPON_SPREAD: parallelCount = 5; break;
        }

        //iter for shot
        foreach (double timestamp in ammosDic.Keys)
        {
            Debug.Log("shotTimestamp: " + timestamp.ToString());
            Debug.Log("nowTimestamp: " + TimeEx.getTimeStamp());

            //when receive timeout, means failing, we just mark it
            if (TimeEx.getTimeStamp() - timestamp > timeout)
            {
                timeoutkeys.Add(timestamp);
                continue;
            }

            //ready for shot
            List <GameObject> ammos = ammosDic[timestamp];
            if (ammos.Count >= parallelCount)
            {
                for (int i = 0; i < ammos.Count; i++)
                {
                    //set transform
                    GameObject ammo   = ammos[i];
                    GameObject master = ammo.GetComponent <Projectile>().m_Master;
                    ammo.transform.position = master.transform.position;
                    ammo.transform.Rotate(0, 20.0f - 10.0f * i, 0);

                    //set sync transfrom
                    SyncPosRot syncScript = ammo.GetComponent <SyncPosRot>();
                    if (!syncScript.isLocalPlayer)
                    {
                        syncScript.RealSync(ammo);
                    }

                    //active
                    ammo.SetActive(true);
                }
                ammos.Clear();
                ammosDic.Remove(timestamp);
                break;
            }
        }

        //clear timeout data
        foreach (double timestamp in timeoutkeys)
        {
            List <GameObject> ammos = ammosDic[timestamp];
            for (int i = 0; i < ammos.Count; i++)
            {
                GameObject ammo = ammos[i];
                ammo.GetComponent <Projectile>().Safe_Destroy();
            }
            ammos.Clear();
            ammosDic.Remove(timestamp);
        }
        timeoutkeys.Clear();
    }