示例#1
0
文件: Creature.cs 项目: mengtest/drog
 public void UpdateCreature()
 {
     if (curCreatureData.curHP <= 0)
     {
         //死亡
         ToUseSkill(DEAD);
     }
     timer.Update();
     BUFFtimer.Update();
     curFSM.Update();
     //浮空受击y轴不移动
     //Debug.Log("UPv " + UPv);
     //if(!IfBeAttacked) {
     //y轴物理位移
     pos.y += (UPv + UPv - G * Logic.eachframtime) * Logic.eachframtime / 2;
     UPv   -= G * Logic.eachframtime;
     //} else if(UPv<0&&pos.y>0) {
     //    Debug.Log("浮空受击");
     //    UPv = 5;
     //}
     if (pos.y <= 0)
     {
         if (UPv < 0)
         {
             UPv = 0;
         }
         pos.y = 0;
     }
     if (IfBeAttacked)
     {
         //Debug.Log("受击态!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
     }
     IfBeAttacked = false;
 }
示例#2
0
 public void Update()
 {
     if (_netManager == null)
     {
         return;
     }
     _netManager.PollEvents();
     _logicTimer.Update();
 }
示例#3
0
    public void Update()
    {
        //if(bu.BulletFireEnemyPos) {

        //} else {
        if (Lockname != "")
        {
            //Debug.Log("锁定 " + Lockname);
            dir = GetDir(pos, Logic.obinfmp[Lockname].pos);
        }
        Move(bu.FlySpeed);
        timer.Update();
        if (Logic.time - BeginTime >= bu.MaxDuringTime)
        {
            ifEnd = true;
        }

        //法术场的持续减速
        if (bu.CutSpeedRatio > 0)
        {
            foreach (var t in Logic.obinfmp)
            {
                var e = Logic.obinfmp[t.Key];
                if (Vector3.Distance(new Vector3(pos.x, 0, pos.z), new Vector3(e.pos.x, 0, e.pos.z)) <= bu.Attack.SkillAttackJudgeAreaRadius + e.curCreatureData.Radius)
                {
                    //TODO:判断敌友
                    if (Logic.obinfmp[Mastername].tag == e.tag)
                    {
                        continue;
                    }
                    e.BUFFtimer.Add((Logic.time + Logic.eachframtime, delegate() {
                        e.curCreatureData.Speed *= bu.CutSpeedRatio > 1?1:(1 - bu.CutSpeedRatio);
                    }));
                    e.BUFFtimer.Add((Logic.time + Logic.eachframtime * 2, delegate() {
                        e.curCreatureData.Speed /= bu.CutSpeedRatio > 1?1:(1 - bu.CutSpeedRatio);
                    }));
                }
            }
        }

        //TOD:攻击判定
        if (bu.FlySpeed > 0)
        {
            AttackJudge();
        }
        if (!bu.IfPenetrate && HitMap.Count > 0)
        {
            ifEnd = true;
        }
        AEJudge(2);
        //}
    }
示例#4
0
    public static void Update()
    {
        /*if(EventHandle != null) {
         *  EventHandle();
         *  EventHandle -= EventHandle;
         * }*/
        UIManager.Update();
        //Debug.Log("user counts " + obmp.Count);
        var obinfmp = Logic.obinfmp;
        var needDes = new List <string>();

        foreach (var e in obinfmp)
        {
            var name  = e.Key;
            var obinf = e.Value;
            //用户不存在就新建
            if (!obmp.ContainsKey(name))
            {
                Debug.Log("new palyer name " + name);
                obmp[name] = GameObject.Instantiate(MyResources[obinf.curCreatureData.Name], obinf.pos, Quaternion.identity);
                //obmp[name].transform.Find("body").GetComponent<SkinnedMeshRenderer>().material = RSDB.mat[obinf.id-1];
                obmp[name].name = name;

                //新建玩家为本机玩家,绑定相机
                if (Client.name == name)
                {
                    var camera = GameObject.Find("Main Camera");
                    camera.GetComponent <FollowPlayer>().player = obmp[name].transform;
                }
            }
            var obt = obmp[name].transform;
            //缓动
            float angle = obinf.rot.y;
            float f     = (float)(angle * Math.PI / 180.0f);
            obt.position = Vector3.Lerp(obt.position, obinf.pos, 0.2f);
            //obt.localEulerAngles = Vector3.Lerp(obt.localEulerAngles, obinf.rot, 0.1f);
            obt.rotation = Quaternion.Slerp(obt.rotation
                                            , Quaternion.LookRotation((new Vector3((float)Math.Sin(f), 0, (float)Math.Cos(f)))), 0.1f);
            obt.Find("HPUI").transform.eulerAngles = new Vector3(0, 0, 0);
            obt.Find("HPUI").Find("Slider").GetComponent <Slider>().value = Logic.obinfmp[name].curCreatureData.curHP / Logic.obinfmp[name].curCreatureData.maxHP;

            Debug.DrawLine(obt.position, obt.position + Quaternion.Euler(0, -45, 0) * obt.forward * 0.8f, Color.white);
            Debug.DrawLine(obt.position, obt.position + Quaternion.Euler(0, -30, 0) * obt.forward * 0.8f, Color.white);
            Debug.DrawLine(obt.position, obt.position + Quaternion.Euler(0, -15, 0) * obt.forward * 0.8f, Color.white);
            Debug.DrawLine(obt.position, obt.position + Quaternion.Euler(0, 0, 0) * obt.forward * 0.8f, Color.white);
            Debug.DrawLine(obt.position, obt.position + Quaternion.Euler(0, 15, 0) * obt.forward * 0.8f, Color.white);
            Debug.DrawLine(obt.position, obt.position + Quaternion.Euler(0, 30, 0) * obt.forward * 0.8f, Color.white);
            Debug.DrawLine(obt.position, obt.position + Quaternion.Euler(0, 45, 0) * obt.forward * 0.8f, Color.white);
        }


        foreach (var t in bullets)
        {
            var e = bullets[t.Key];
            var b = BulletsManager.buob[t.Key];
            e.transform.position    = Vector3.Lerp(e.transform.position, new Vector3(b.pos.x, e.transform.position.y, b.pos.z), 0.7f);
            e.transform.eulerAngles = b.rot;
            //Debug.Log("view " + b.rot);
        }

        //timer.First();
        timer.Update();
        //if(EventHandle != null) {
        //    EventHandle();
        //    EventHandle -= EventHandle;
        //}
    }
 public override void Update()
 {
     _netManager.PollEvents();
     _logicTimer.Update();
 }
示例#6
0
 private void Update()
 {
     _netManager.PollEvents();
     _logicTimer.Update();
 }
示例#7
0
文件: FSM.cs 项目: mengtest/drog
 /// <summary>
 /// 状态更新时的操作
 /// </summary>
 public void OnUpdate()
 {
     //Debug.Log("state update");
     timer.Update();
 }
示例#8
0
        static void Main(string[] args)
        {
            var config = new GravityConfig()
            {
                AutoGenerateParticleData   = true,
                GeneratedParticleDataCount = 75,

                ParticleCount = 1500,

                MinimumInitialPositionX = 0,
                MaximumInitialPositionX = 15000,

                MinimumInitialPositionY = 0,
                MaximumInitialPositionY = 15000,

                MinimumMass = 6,
                MaximumMass = 150,


                MinimumInitialVelocity = -50,
                MaximumInitialVelocity = 50,

                BatchCount = 125
            };

            //var scene = new TwoBodyCollisionScene();
            //var config = scene.Config;

            var logicController = new LogicController(config);
            var window          = new Window(config);
            var space           = logicController.StartLogic();

            space.Particles.Add(
                logicController.ParticleController.CreateParticle(new GravityParticleData(1000000, 850, Color.Yellow), new Vector2(7400, 7400))
                );

            space.Particles.Add(
                logicController.ParticleController.CreateParticle(new GravityParticleData(1100000, 750, Color.Blue), new Vector2(9400, 7400))
                );

            space.Particles.Add(
                logicController.ParticleController.CreateParticle(new GravityParticleData(1100000, 950, Color.Red), new Vector2(8400, 5400))
                );
            //scene.Initialize(logicController, space);

            window.Run();

            var stopwatch    = new Stopwatch();
            var fpsStopwatch = new Stopwatch();

            var ms = new List <double>();

            fpsStopwatch.Start();

            var timer = new LogicTimer(() =>
            {
                stopwatch.Restart();

                logicController.UpdateLogic(space);
                window.Update(space.Particles);

                if (fpsStopwatch.ElapsedMilliseconds >= 1000)
                {
                    fpsStopwatch.Restart();
                    if (ms.Count > 0)
                    {
                        Console.WriteLine("Average FPS: " + ms.Average());
                    }
                    ms.Clear();
                }

                stopwatch.Stop();

                ms.Add(1000.0 / stopwatch.Elapsed.TotalMilliseconds);

                LogicTimer.DeltaTime = 1f / (1000f / (float)stopwatch.Elapsed.TotalMilliseconds);

                if (LogicTimer.DeltaTime < LogicTimer.FixedDelta)
                {
                    LogicTimer.DeltaTime = LogicTimer.FixedDelta;
                }
            });

            timer.Start();

            while (true)
            {
                timer.Update();
            }
        }