public PartnerFar(Vector2 position, PhysicObj target) : base(position, target) { height = 0; Animation anim = new Animation(Bloodbender.ptr.Content.Load <Texture2D>("Pair/coursePair2"), 7, 0.1f, 0, 0, 0, 0); anim.reset(); addAnimation(anim); Animation attackAnimation = new Animation(Bloodbender.ptr.Content.Load <Texture2D>("Pair/attackPair2"), 7, 0.075f, 0, 0, 0, 0); attackAnimation.isLooping = false; addAnimation(attackAnimation); Bloodbender.ptr.shadowsRendering.addShadow(new Shadow(this)); fixture = createOctogoneFixture(50f, 50f, Vector2.Zero, new AdditionalFixtureData(this, HitboxType.BOUND)); Radius = 50f; velocity = _initialVelocity; addFixtureToCheckedCollision(fixture); _node = new PhysicObj(new Vector2(position.X, position.Y), PathFinderNodeType.CENTER); _node.createOctogoneFixture(10, 10, Vector2.Zero, new AdditionalFixtureData(_node, HitboxType.BOUND)).IsSensor = true; _node.Radius = 10.0f; IComponent comp = new KeepDistanceComponent(300, Bloodbender.ptr.player, _node, this); _node.addComponent(comp); IComponent comp2 = new FollowBehaviorComponent(this, _node, 0); addComponent(comp2); distanceAttackWithTarget = 400; canAttack = true; canGenerateProjectile = true; canBeHitByPlayer = false; canBeHitByProjectile = false; }
public PartnerClose(Vector2 position, PhysicObj target) : base(position, target) { height = 0; Animation anim = new Animation(Bloodbender.ptr.Content.Load <Texture2D>("Pair/coursePair1"), 7, 0.1f, 0, 0, 0, 0); anim.reset(); addAnimation(anim); Animation attackAnimation = new Animation(Bloodbender.ptr.Content.Load <Texture2D>("Pair/attackPair1"), 9, 0.075f, 0, 0, 0, 0); attackAnimation.isLooping = false; addAnimation(attackAnimation); Bloodbender.ptr.shadowsRendering.addShadow(new Shadow(this)); fixture = createOctogoneFixture(50f, 50f, Vector2.Zero, new AdditionalFixtureData(this, HitboxType.BOUND)); Radius = 50f; velocity = 30; fixture.OnCollision += Collision; addFixtureToCheckedCollision(fixture); Partner = null; IComponent comp = new FollowBehaviorComponent(this, target, 40f); addComponent(comp); distanceAttackWithTarget = 50; lifePoints = 2; canAttack = true; canGenerateProjectile = false; canBeHitByPlayer = false; canBeHitByProjectile = true; cacAttack = true; }
public List <PathFinderNode> pathRequest(PhysicObj startObj, PhysicObj endObj) { var stopwatch = new System.Diagnostics.Stopwatch(); startObj.getPosNode().neighbors.Remove(endObj.getPosNode()); endObj.getPosNode().neighbors.Remove(startObj.getPosNode()); RemoveNodeFromNavMesh(GetNavMesh(startObj), startObj.getPosNode()); RemoveNodeFromNavMesh(GetNavMesh(startObj), endObj.getPosNode()); AddNodeToNavMesh(GetNavMesh(startObj), startObj.getPosNode()); AddNodeToNavMesh(GetNavMesh(startObj), endObj.getPosNode()); if (PathProcessor.isWayClearToNode(startObj, endObj.getPosNode())) { //startObj.getPosNode().neighbors.Add(endObj.getPosNode()); //endObj.getPosNode().neighbors.Add(startObj.getPosNode()); return(new List <PathFinderNode>() { startObj.getPosNode(), endObj.getPosNode() }); //GetNavMesh(startObj).graph.AddEdge(new Edge<PathFinderNode>(startObj.getPosNode(), endObj.getPosNode())); } //startObj.getPosNode().reset(); //endObj.getPosNode().reset(); //navMeshes.ForEach(nav => nav.Nodes.ForEach(node => node.reset())); //var resultPath = pathProc.runDjikstra(startObj.getPosNode(), endObj.getPosNode()); //var res = GetNavMesh(startObj).graph.ShortestPathsDijkstra(GetNavMesh(startObj).verticesDistance, startObj.getPosNode()); if (GetNavMesh(startObj).graph.ContainsVertex(startObj.getPosNode())) { stopwatch.Start(); var res = GetNavMesh(startObj).graph.ShortestPathsDijkstra(GetNavMesh(startObj).verticesDistance, startObj.getPosNode()); IEnumerable <Edge <PathFinderNode> > path; if (res(endObj.getPosNode(), out path)) { var list = path.ToList(); var list2 = new List <PathFinderNode>();// { startObj.getPosNode() }; foreach (var edge in list) { //if (list2[list2.Count - 1] == edge.Source) //list2.Add(edge.Target); //else list2.Add(edge.Source); } stopwatch.Stop(); //Console.WriteLine(stopwatch.ElapsedMilliseconds); return(list2); } } //if (resultPath != null) //{ // PathDict[startObj] = resultPath; // return resultPath; //} return(null); }
public NavMesh GetNavMesh(PhysicObj obj) { return(objNavMeshMapping[obj]); }
public void UpdateTriangleForObj(PhysicObj obj) { AddNodeToNavMesh(GetNavMesh(obj), obj.getPosNode()); }
public KeepDistanceComponent(float distance, PhysicObj target, PhysicObj owner, PhysicObj guarded) { _owner = owner; _distance = distance * Bloodbender.pixelToMeter; _target = target; _guarded = guarded; }