当前位置: 首页>>代码示例>>C#>>正文


C# Agent.getPosition方法代码示例

本文整理汇总了C#中Agent.getPosition方法的典型用法代码示例。如果您正苦于以下问题:C# Agent.getPosition方法的具体用法?C# Agent.getPosition怎么用?C# Agent.getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Agent的用法示例。


在下文中一共展示了Agent.getPosition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) {
                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

示例4: 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

示例5: Update


//.........这里部分代码省略.........
                        }
                        else if (m.linkedPickupGen.itemType == PickUp.PickUpType.AMMO) {
                            if (dist < closestAmmoDist) {
                                closestAmmoDist = dist;
                                closestAmmo = m;
                            }
                        }
                        else if (dist < closestUpgradeDist) {
                            closestUpgradeDist = dist;
                            closestUpgrade = m;
                        }
                    }
                }

                //now decide what to do, but how? we calculate a score for each value between 0 and 1
                double agentScore = Math.Min(1, Math.Max(0, (closestAgent == null || closestFeasibleTargetDist >= sightRadius ?
                                        0 : Math.Pow((sightRadius - closestFeasibleTargetDist) / sightRadius, 0.4)))),
                       healthScore = Math.Min(1, Math.Max(0, (closestHealth == null ?
                                        0 : Math.Pow((double)(70 - health)/maxHealth, 2)))),
                       ammoScore = Math.Min(1, Math.Max(0, (closestAmmo == null ?
                                        0 : Math.Pow((double)(maxAmmo - ammo)/maxAmmo, 3)))),
                       upgradeScore = Math.Min(1, Math.Max(0, (closestUpgrade == null ?
                                        0 : Math.Pow((double)(2 - weaponTier) / 2, 4))));

                //find the max
                double maxScore = Math.Max(agentScore, Math.Max(healthScore, Math.Max(ammoScore, upgradeScore)));

                //do the work
                if (maxScore > 0) {
                    ignore.Clear();
                    if (agentScore == maxScore) {
                        Console.WriteLine("going for agent: " + closestAgent);
                        agentTarget = closestAgent;
                        setPathTo(core.aiEngine.findClosestMeshNode(agentTarget.getPosition(), 100, ignore), ignore);
                    }
                    else if (healthScore == maxScore) {
                        Console.WriteLine("going for health: " + closestHealth);
                        setPathTo(closestHealth, null);
                    }
                    else if (ammoScore == maxScore) {
                        Console.WriteLine("going for ammo: " + closestAmmo);
                        setPathTo(closestAmmo, null);
                    }
                    else {
                        Console.WriteLine("going for upgrade: " + closestUpgrade);
                        setPathTo(closestUpgrade, null);
                    }
                }
            }

            if (agentTarget != null && (agentTarget == this || agentTarget.spawnTime > 0))
                agentTarget = null;

            if(agentTarget != null) {
                //walking towards the target
                if (path.Count == 0)
                    setPathTo(core.aiEngine.findClosestMeshNode(agentTarget.getPosition(), 100, ignore), ignore);
                Vector3 aCent = agentTarget.getCenter();
                Vector3 cent = position + new Vector3(0, size.Y / 2, 0);
                direction = getDirectionFromVector(Vector3.Normalize(aCent - cent));
                //shooting the target
                curAgentShootTime -= (float)gameTime.ElapsedGameTime.TotalSeconds;
                if (curAgentShootTime <= 0 && equipped.curCooldown <= 0) {
                    curAgentShootTime = agentShootTime;
                    //try and shoot the player
                    PhysicsEngine.HitScan hs = core.physicsEngine.hitscan(cent, aCent - cent, null);
开发者ID:elliottroland,项目名称:Emergence,代码行数:67,代码来源:AIAgent.cs


注:本文中的Agent.getPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。