예제 #1
0
 protected override void LoadData()
 {
     Data          = Gamef.LoadSkillData(SkillName.Lazer);
     missilePrefab = Data.Prefabs[0];
     if (missilePrefab == null)
     {
         Debug.LogError("未能找到 Lazer Prefab");
     }
 }
예제 #2
0
 protected override void LoadData()
 {
     Data          = Gamef.LoadSkillData(SkillName.TestStrafeSkill);
     missilePrefab = Data.Prefabs[0];
     if (missilePrefab == null)
     {
         Debug.LogError("未能找到 Ice ball prefab");
     }
 }
예제 #3
0
 void Death()
 {
     IsAlive = false;
     specialEffectHandler.CreateDestroyEffect(Caster, this, deathEffect);
     if (Enemy != null)
     {
         trackSystem?.StopTracking();
     }
     Gamef.MissileClear(ID);
     Gamef.Destroy(gameObject);
 }
예제 #4
0
    protected override Missile Shoot()
    {
        Vector3 dir = Gamef.GenerateRandomDirection(Caster.SpawnTransform.forward, Caster.RuntimeAccuracy, random);

        tmp = Gamef.Instantiate(missilePrefab, SpawnTransform.position, Quaternion.LookRotation(dir));
        Missile missile = tmp.GetComponent <Missile>();

        missile.Init(Caster, Target, this);
        Caster.RuntimeAccuracy -= Data.AccuracyHeatupSpeed;
        return(missile);
    }
예제 #5
0
 protected virtual void Death()
 {
     IsAlive = false;
     if (Enemy != null)
     {
         trackSystem?.StopTracking();
     }
     Gamef.MissileClear(ID);
     OnDeath.Invoke();
     StartCoroutine(DelayDestroy());
 }
    protected override Missile Shoot()
    {
        Vector3 dir = Gamef.GenerateRandomDirection(Caster.SpawnTransform.forward, Caster.RuntimeAccuracy, random);

        tmp = Gamef.Instantiate(missilePrefab, SpawnTransform.position, Quaternion.LookRotation(dir));
        Missile missile = tmp.GetComponent <Missile>();

        missile.Init(Caster, Target, this, new MissileHitBasicHandler(), new FireBallEffectHandler());
        //Debug.Log("Strafe Accuracy : " + Caster.RuntimeAccuracy);
        Caster.RuntimeAccuracy -= Data.AccuracyHeatupSpeed;
        return(missile);
    }
 public void HitUnit(Missile self, Unit unit)
 {
     if (self.Skill.Data.IsAOE)
     {
         self.Blast(null);
     }
     else
     {
         Gamef.Damage(self.Damage, DamageType.unset, self.Caster, unit);
     }
     self.TakeDamage(1e7f);
 }
예제 #8
0
        public static void SyncMouseButton0Up(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            long instant = proto.GetInt(start, ref start);
            int  id      = proto.GetByte(start, ref start);
            Unit unit    = Gamef.GetUnit(id);

            unit.SyncPlayerInput.SyncMouseButton0Up(instant);
        }
예제 #9
0
        public static void DestroyObj(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            long instant = proto.GetInt(start, ref start);
            int  id      = proto.GetByte(start, ref start);
            Unit unit    = Gamef.GetUnit(id);

            //Destroy the object.
            unit.Death();
        }
예제 #10
0
        public static void SyncStop(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            long instant    = proto.GetInt(start, ref start);
            int  id         = proto.GetByte(start, ref start);
            int  skillIndex = proto.GetByte(start, ref start);
            Unit unit       = Gamef.GetUnit(id);

            unit.SyncPlayerCastingState.SyncStop(instant, skillIndex);
        }
예제 #11
0
        public static void SyncMP(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            long  instant = proto.GetInt(start, ref start);
            int   id      = proto.GetByte(start, ref start);
            Unit  unit    = Gamef.GetUnit(id);
            float val     = proto.GetFloat(start, ref start);

            unit.SyncUnitState.SyncMP(instant, val);
        }
    protected override Missile Shoot()
    {
        Debug.Log(string.Format("ID {0} test burst start at {1}", Caster.attributes.ID, Gamef.SystemTimeInMillisecond));
        Vector3 dir = Gamef.GenerateRandomDirection(Caster.SpawnTransform.forward, Caster.RuntimeAccuracy, random);

        tmp = Gamef.Instantiate(missilePrefab, SpawnTransform.position, Quaternion.LookRotation(dir));
        Missile missile = tmp.GetComponent <Missile>();

        missile.Init(Caster, Target, this, new MissileHitBasicHandler(), new FireBallEffectHandler());
        //Debug.Log("Strafe Accuracy : " + Caster.RuntimeAccuracy);
        Caster.RuntimeAccuracy -= Data.AccuracyHeatupSpeed;
        return(missile);
    }
예제 #13
0
    protected override Missile Shoot()
    {
        Vector3 dir = Gamef.GenerateRandomDirection(Caster.SpawnTransform.forward, Caster.RuntimeAccuracy, random);

        tmp = Gamef.Instantiate(missilePrefab, SpawnTransform.position, Quaternion.LookRotation(dir));
        //if (GameCtrl.IsVR)
        //    Gamef.ControllerVibration(0f, 0.1f, 160, 0.5f, Valve.VR.SteamVR_Input_Sources.RightHand);
        Missile missile = tmp.GetComponent <Missile>();

        missile.Init(Caster, Target, this);
        //Debug.Log("Strafe Accuracy : " + Caster.RuntimeAccuracy);
        Caster.RuntimeAccuracy -= Data.AccuracyHeatupSpeed;
        return(missile);
    }
예제 #14
0
        public static void SyncTransform(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            long       instant  = proto.GetInt(start, ref start);
            int        id       = proto.GetByte(start, ref start);
            Unit       unit     = Gamef.GetUnit(id);
            Vector3    position = ParseVector3(proto, ref start);
            Quaternion rot      = ParseQuaternion(proto, ref start);
            float      speed    = proto.GetFloat(start, ref start);

            unit.SyncMovement.SyncTransform(instant, position, rot, speed);
        }
예제 #15
0
        public static void SyncMobileControlAxes(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            long instant = proto.GetInt(start, ref start);           //parse instant
            int  id      = proto.GetByte(start, ref start);          //parse id

            int[]   hv  = ParseHaV(proto.GetByte(start, ref start)); //parse h and v
            Vector3 fwd = ParseVector3(proto, ref start);            // parse camera forward

            Unit unit = Gamef.GetUnit(id);

            unit.SyncPlayerInput.SyncMobileControlAxes(instant, hv[0], hv[1], fwd);
        }
예제 #16
0
    /// <summary>
    /// 外部可以通过该接口对单位进行初始化。
    /// </summary>
    /// <param name="ID">单位ID</param>
    public void InitAttributes(int ID)
    {
        if (isInitAttr)
        {
            return;
        }
        isInitAttr = true;
        //注册单位
        lock (GameDB.unitPool)
            attributes.ID = Gamef.UnitBirth(this, ID);

        attributes.Init(this);
        // 如果该单位是施法单位,则初始化技能表
        if (attributes.data.IsCaster)
        {
            skillTable.Init(this);
        }
    }
예제 #17
0
        public static void SyncAimTarget(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            long instant  = proto.GetInt(start, ref start);
            int  sourceId = proto.GetByte(start, ref start);
            int  targetId = proto.GetByte(start, ref start);

            if (targetId == 255)
            {
                targetId = -1;
            }
            Unit unit = Gamef.GetUnit(sourceId);

            Debug.Log(string.Format("Send sync target ID {0} -> ID {1}", sourceId, targetId));
            unit.SyncPlayerCastingState.SyncTarget(instant, Gamef.GetUnit(targetId));
        }
예제 #18
0
    /// <summary>
    /// 获得离摄像机最近的单位。最近指单位在镜头上的2D位置离镜头中央最近,即“看起来”最近。
    /// </summary>
    /// <returns>最近的单位</returns>
    public Unit GetClosestUnit()
    {
        Unit player = GameCtrl.PlayerUnit;

        if (player == null)
        {
            return(null);
        }

        IEnumerator <Unit> it = Gamef.GetUnitEnumerator();
        Unit    resUnit       = null;
        float   minAngle      = GameDB.MAX_AIMING_ANGLE;
        Vector3 fwd           = transform.forward;
        Vector3 pos           = transform.position;
        Unit    tmp;

        do
        {
            tmp = it.Current;
            if (tmp != player)
            {
                if (tmp == null)
                {
                    Debug.Log("???");
                    it.Reset();
                    tmp = it.Current;
                }
                float angle = Vector3.Angle(fwd, tmp.transform.position - pos);
                if (angle < minAngle)
                {
                    minAngle = angle;
                    resUnit  = tmp;
                }
            }
        } while (it.MoveNext());
        Debug.Log("Unit Closest to Player is " + (resUnit == null ? "null" : resUnit.gameObject.name));
        return(resUnit);
    }
예제 #19
0
    public virtual void Reset(params object[] Params)
    {
        BuffName name;
        Unit     target;
        Unit     caster;

        if (Params.Length == 4)
        {
            BuffData data;
            if (Params[0] is BuffName && Params[1] is Unit && Params[2] is Unit && Params[3] is BuffData)
            {
                name   = (BuffName)Params[0];
                target = Params[1] as Unit;
                caster = Params[2] as Unit;
                data   = Params[3] as BuffData;
                //
                this.data   = data;
                this.target = target;
                this.caster = caster;
                Start();
            }
        }
        else if (Params.Length == 3)
        {
            if (Params[0] is BuffName && Params[1] is Unit && Params[2] is Unit)
            {
                name   = (BuffName)Params[0];
                target = Params[1] as Unit;
                caster = Params[2] as Unit;
                //
                data        = Gamef.LoadBuffData(name);
                this.target = target;
                this.caster = caster;
                Start();
            }
        }
    }
예제 #20
0
 private void OnDestroy()
 {
     //注销单位
     lock (GameDB.unitPool)
         Gamef.UnitClear(this);
 }
예제 #21
0
 public override void Update()
 {
     base.Update();
     Gamef.Damage(data.Effect * Time.deltaTime, DamageType.unset, caster, target);
     Gamef.Heal(data.Params[0] * Time.deltaTime, caster, caster);
 }
예제 #22
0
    public void Blast(Missile exception)
    {
        float     dis, damage = Skill.Data.Damage;
        BlastType type;

        // 制造爆炸力(物理效果)
        physicalEffectHandler.CreateExplosiveForce(Skill.Data, transform.position);

        //对单位造成AOE伤害
        GameDB.unitPool.Traversal(delegate(Unit other)
        {
            if (!other.attributes.isAlive)
            {
                return;
            }
            dis = (other.transform.position - transform.position).magnitude;
            if (dis > Skill.Data.OuterBlastRadius)
            {
                //do nothing
            }
            else
            {
                if (dis > Skill.Data.MiddleBlastRadius)
                {
                    //外圈伤害
                    damage = Skill.Data.Damage * Skill.Data.OuterDamageCoefficient;
                    type   = BlastType.Outer;
                }
                else
                {
                    if (dis > Skill.Data.InnerBlastRadius)
                    {
                        //中圈伤害
                        damage = Skill.Data.Damage * Skill.Data.MiddleDamageCoefficient;
                        type   = BlastType.Middle;
                    }
                    else
                    {
                        //内圈伤害
                        damage = Skill.Data.Damage * Skill.Data.InnerDamageCoefficient;
                        type   = BlastType.Inner;
                    }
                }
                Gamef.Damage(damage, DamageType.unset, Caster, other);
                unitHandler?.Invoke(other, type);
            }
        });

        //对投掷物造成AOE伤害
        GameDB.missilePool.Traversal(delegate(Missile other)
        {
            if (!other.IsAlive)
            {
                return;
            }
            //忽略碰撞到的投掷物
            if (other == exception)
            {
                missileHandler?.Invoke(other, BlastType.Inner);
                return;
            }
            if (other == this)
            {
                return;
            }
            dis = (other.transform.position - transform.position).magnitude;
            if (dis > Skill.Data.OuterBlastRadius)
            {
                //do nothing
            }
            else
            {
                if (dis > Skill.Data.MiddleBlastRadius)
                {
                    //外圈伤害
                    damage = Skill.Data.Damage * Skill.Data.OuterDamageCoefficient;
                    type   = BlastType.Outer;
                }
                else
                {
                    if (dis > Skill.Data.InnerBlastRadius)
                    {
                        //中圈伤害
                        damage = Skill.Data.Damage * Skill.Data.MiddleDamageCoefficient;
                        type   = BlastType.Middle;
                    }
                    else
                    {
                        //内圈伤害
                        damage = Skill.Data.Damage * Skill.Data.InnerDamageCoefficient;
                        type   = BlastType.Inner;
                    }
                }
                other.TakeDamage(damage);
                missileHandler?.Invoke(other, type);
            }
        });
    }
예제 #23
0
    IEnumerator DelayDestroy()
    {
        yield return(new WaitForSeconds(DestroyDelay));

        Gamef.Destroy(gameObject);
    }
예제 #24
0
 protected override void Stop()
 {
     Caster.attributes.MaxV_bonus = original;
     Gamef.Destroy(tmp);
     Debug.Log("哦豁,您成功停止了速度提升技能!");
 }
예제 #25
0
 protected override void Stop()
 {
     Gamef.Destroy(tmp);
     Debug.Log("哦豁,您成功停止了生命恢复技能!");
 }
 protected override void LoadData()
 {
     Data = Gamef.LoadSkillData(SkillName.TestContinuousSkill);
 }
예제 #27
0
 public void SyncStop(long instant, int skillIndex)
 {
     Debug.Log("ID " + unit.attributes.ID + ": " + "try to stop skill " + skillIndex + " at " + instant);
     Gamef.StartCoroutine(TryStop(instant, skillIndex));
 }
 protected override void LoadData()
 {
     Data = Gamef.LoadSkillData(SkillName.TestBurstfireSkill);
 }