當前位置: 首頁>>代碼示例>>C#>>正文


C# Agent.getDirectionVector方法代碼示例

本文整理匯總了C#中Agent.getDirectionVector方法的典型用法代碼示例。如果您正苦於以下問題:C# Agent.getDirectionVector方法的具體用法?C# Agent.getDirectionVector怎麽用?C# Agent.getDirectionVector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Agent的用法示例。


在下文中一共展示了Agent.getDirectionVector方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: fire

        public override void fire(Agent p, PhysicsEngine ph)
        {
            base.fire(p, ph);

            if (curCooldown == cooldown) {
                Random rand = new Random();
                Vector3 dir = Vector3.Normalize(p.getDirectionVector());
                Vector3 right = Vector3.Cross(dir, Vector3.Up);
                Vector3 up = Vector3.Cross(dir, right);
                up *= inaccuracy;
                right *= inaccuracy;
                dir = dir + (float)(rand.NextDouble() * 2 - 1) * up + (float)(rand.NextDouble() * 2 - 1) * right;
                inaccuracy = Math.Min(maxInaccuracy, inaccruacyJump + inaccuracy);
                inaccuracyCurCooldown = 0;

                List<Agent> l = new List<Agent>();
                l.Add(p);
                PhysicsEngine.HitScan hs = ph.hitscan(p.getPosition() + new Vector3(0, 75, 0) + p.getDirectionVector() * 10, p.getDirectionVector(), null);
                PhysicsEngine.AgentHitScan ahs = ph.agentHitscan(p.getPosition() + new Vector3(0, 60, 0) + p.getDirectionVector() * 10, dir, l);
                if (hs != null && (ahs == null || hs.Distance() < ahs.Distance()))
                    makeLaser(p, hs.ray, Vector3.Distance(hs.ray.Position, hs.collisionPoint), 5, 5, "Rifle");
                else if (ahs != null) {
                    ahs.agent.dealDamage(damage, p);
                    makeLaser(p, ahs.ray, Vector3.Distance(ahs.ray.Position, ahs.collisionPoint), 5, 5, "Rifle");
                }
            }
        }
開發者ID:elliottroland,項目名稱:Emergence,代碼行數:27,代碼來源:Rifle.cs

示例2: fire

        public override void fire(Agent p, PhysicsEngine ph)
        {
            base.fire(p, ph);

            if (curCooldown == cooldown) {
                Random rand = new Random();
                Vector3 [] dirs = new Vector3[5];
                dirs[0] = Vector3.Normalize(p.getDirectionVector());
                Vector3 right = Vector3.Cross(dirs[0], Vector3.Up);
                Vector3 up = Vector3.Cross(dirs[0], right);
                up *= 0.15f;
                right *= 0.15f;
                dirs[1] = dirs[0] + (float)rand.NextDouble() * right + (float)rand.NextDouble() * up;
                dirs[2] = dirs[0] + (float)rand.NextDouble() * right - (float)rand.NextDouble() * up;
                dirs[3] = dirs[0] - (float)rand.NextDouble() * right - (float)rand.NextDouble() * up;
                dirs[4] = dirs[0] - (float)rand.NextDouble() * right + (float)rand.NextDouble() * up;

                foreach(Vector3 dir in dirs)    {
                    List<Agent> l = new List<Agent>();
                    l.Add(p);
                    PhysicsEngine.HitScan hs = ph.hitscan(p.getPosition() + new Vector3(0, 75, 0) + p.getDirectionVector() * 10, dir, null);
                    PhysicsEngine.AgentHitScan ahs = ph.agentHitscan(p.getPosition() + new Vector3(0, 75, 0) + p.getDirectionVector() * 10, dir, l);
                    if (hs != null && (ahs == null || hs.Distance() < ahs.Distance()))
                        makeLaser(p, hs.ray, Vector3.Distance(hs.ray.Position, hs.collisionPoint), 5, 5, "Shotgun");
                    else if (ahs != null) {
                        ahs.agent.dealDamage(damage, p);
                        makeLaser(p, ahs.ray, Vector3.Distance(ahs.ray.Position, ahs.collisionPoint), 5, 5, "Shotgun");
                    }
                }
            }
        }
開發者ID:elliottroland,項目名稱:Emergence,代碼行數:31,代碼來源:Shotgun.cs

示例3: fire

 public override void fire(Agent p, PhysicsEngine ph)
 {
     base.fire(p, ph);
     if (curCooldown == cooldown) {
         PhysicsEngine.HitScan hs = ph.hitscan(p.getPosition() + new Vector3(0, 75, 0) + p.getDirectionVector() * 10, p.getDirectionVector(), null);
         if (hs != null) {
             makeRocket(p, hs.ray, Vector3.Distance(hs.ray.Position, hs.collisionPoint), 1200, 40);
         }
     }
 }
開發者ID:elliottroland,項目名稱:Emergence,代碼行數:10,代碼來源:RocketLauncher.cs

示例4: fire

        public override void fire(Agent p, PhysicsEngine ph)
        {
            base.fire(p, ph);

            if (curCooldown == cooldown) {
                List<Agent> l = new List<Agent>();
                l.Add(p);
                PhysicsEngine.HitScan hs = ph.hitscan(p.getPosition() + new Vector3(0, 75, 0) + p.getDirectionVector() * 10, p.getDirectionVector(), null);
                PhysicsEngine.AgentHitScan ahs = ph.agentHitscan(p.getPosition() + new Vector3(0, 60, 0) + p.getDirectionVector() * 10, p.getDirectionVector(), l);
                if (hs != null && (ahs == null || hs.Distance() < ahs.Distance()))
                    makeLaser(p, hs.ray, Vector3.Distance(hs.ray.Position, hs.collisionPoint), 10, 10, "Railgun");
                else {
                    if (ahs != null) {
                        ahs.agent.dealDamage((int)damage, p);
                        makeLaser(p, ahs.ray, Vector3.Distance(ahs.ray.Position, ahs.collisionPoint), 10, 10, "Railgun");
                    }
                }
            }
        }
開發者ID:elliottroland,項目名稱:Emergence,代碼行數:19,代碼來源:Railgun.cs


注:本文中的Agent.getDirectionVector方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。