Ejemplo n.º 1
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();
    }
Ejemplo n.º 2
0
    void waitShot()
    {
        //iter for shot
        foreach (double timestamp in arrowsDic.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;
            }

            //calculate count
            List <GameObject> arrows    = arrowsDic[timestamp];
            AttackType        attckType = 0;
            int parallelCount           = 1;
            if (arrows.Count > 0)
            {
                KBEngine.Arrow kbeArrow = (KBEngine.Arrow)arrows[0].GetComponent <SyncPosRot>().entity;
                attckType = (AttackType)kbeArrow.attackType;
                switch (attckType)
                {
                case AttackType.Frozen:
                    parallelCount = 5;
                    break;

                case AttackType.Normal:
                case AttackType.Strong:
                case AttackType.Shadow:
                    parallelCount = 1;
                    break;
                }
            }

            //ready for shot
            if (arrows.Count >= parallelCount)
            {
                GameObject master = null;
                for (int i = 0; i < arrows.Count; i++)
                {
                    //set transform
                    GameObject arrow = arrows[i];
                    if (arrow.GetComponent <SyncPosRot>().isLocalPlayer)
                    {
                        master = arrow.GetComponent <Arrow>().master;
                        arrow.transform.position = getShotTrans(master).position;
                        float delta  = 15f;
                        float yAngle = (int)((i + 1) / 2) * (i % 2 == 0 ? delta : -delta);
                        arrow.transform.Rotate(0, yAngle, 0);
                    }

                    //active
                    arrow.SetActive(true);
                }
                if (master != null)
                {
                    master.GetComponent <SyncPosRot>().entity.cellCall("reqActiveArrows", new object[] { timestamp });
                }
                arrows.Clear();
                arrowsDic.Remove(timestamp);

                break;
            }
        }

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