static void DrawGizmoForMyScript(AntMovement scr, GizmoType gizmoType) { Transform transform = scr.gameObject.transform; //if (Vector3.Distance(position, Camera.current.transform.position) > 10f) //Gizmos.DrawIcon(transform.position, "arrow.tiff", true); Gizmos.DrawLine(transform.position, transform.position + transform.up); }
//運搬能力 //public int ability = 1; // Start is called before the first frame update void Start() { antMovement = new AntMovement(); //目的地の設定 //餌と巣の位置情報はテスト用(後で削除または変更する可能性あり) //餌の位置 targetFeed = GameObject.Find("feed").transform.position; //巣の位置 targetNest = GameObject.Find("nest").transform.position; //現在置 //自身の座標を取得 antMovement.nowPlace = transform.position; //経路探索のプログラムにぶち込むためのnode作成 nodeGraph = new NodeGraph(); nodeNest = nodeGraph.CreateNode(targetNest); nodeFeed = nodeGraph.CreateNode(targetFeed); //現在は曲がり角を生成していないため、nodeは2つだけ //試しにtargetNestEntrance(巣の出入り口)なるものを曲がり角として用意してみる targetNestEntrance = GameObject.Find("nestEntrance").transform.position; nodeNestEntrance = nodeGraph.CreateNode(targetNestEntrance); //nodeをそれぞれつなげる作業 //nodeGraph.ConnectNodes(new []{from,to});→ fromからtoへnodeをつなげる //nodeGraph.ConnectNodes(new []{A, B,C});→ABCの循環円を作成 nodeGraph.ConnectNodes(new [] { nodeNest, nodeNestEntrance }); nodeGraph.ConnectNodes(new [] { nodeNestEntrance, nodeFeed }); //探索ごとにAStarSearcherインスタンスを作る searcher = new AStarSearcher(nodeGraph); //経路探索をする searcher.SearchRoute(nodeNest, nodeFeed); Debug.Log(searcher.Route); //結果はsearcher.Routeに入る foreach (var node in searcher.Route) { //vにnode.Posで値を取得する v.Add(node.WorldPosition); //Debug.Log(node.ToString()); I++; //vの大きさ } //ありの状態の取得 //初期位置 antMovement.nowPlace = transform.position; //アリのスピード取得(未取得) //public float speed = hogehoge.speed; //試験用スピード //これは後で削除 antMovement.speed = 0.01f; //node間の移動を計算し足していく値 //最初は1番目の目的地へと向かう i = 1; target = v[i]; antMovement.way = antMovement.Explore(target); }
void Start() { data = (ErgateAntData)GetComponent <ErgateAnt>().Data; antMovement = GetComponent <AntMovement>(); //目的地の設定 var elements = NestSystem.Instance.NestElements; Debug.Log(NestSystem.Instance.NestElements.Count); foreach (var element in elements) { if (element.GetType().Name.Equals("StoreRoom")) { nodeNest = element.GetNodes().ElementAt(0); } /* * else if (element.GetType().Name.) * { * * } */ } nodeFeed = NestSystem.Instance.NestElements[0].GetNodes().ElementAt(0); //餌と巣の位置情報はテスト用(後で削除または変更する可能性あり) //現在置 //自身の座標を取得 antMovement.nowPlace = transform.position; //探索ごとにAStarSearcherインスタンスを作る IEnumerable <IPathNode> routes = NestSystem.Instance.FindRoute(nodeNest, nodeFeed); //結果はsearcher.Routeに入る foreach (var node in routes) { Debug.Log(node.WorldPosition); v.Add(node.WorldPosition); I++; } //ありの状態の取得 //初期位置 antMovement.nowPlace = transform.position; //アリのスピード取得(未取得) //public float speed = hogehoge.speed; //試験用スピード //これは後で削除 antMovement.speed = 0.01f; //node間の移動を計算し足していく値 //最初は1番目の目的地へと向かう i = 1; target = v[i]; antMovement.way = antMovement.Explore(target); }
public bool DEBUG_ANT = false; // Used for debugging // Use this for initialization void Start() { oldNest = GameObject.Find(Naming.World.InitialNest).NestManager(); carryPosition = transform.Find(Naming.Ants.CarryPosition); sensesCol = transform.Find(Naming.Ants.SensesArea).GetComponent <Collider>(); move = gameObject.AntMovement(); nestThreshold = RandomGenerator.Instance.NormalRandom(Other.v[Other.QualityThreshMean], Other.v[Other.QualityThreshNoise]); perceivedQuality = float.MinValue; finishedRecruiting = false; //make sure the value is within contraints if (nestThreshold > 1) { nestThreshold = 1; } else if (nestThreshold < 0) { nestThreshold = 0; } }
// Use this for initialization void Start() { this.oldNest = GameObject.Find("OldNest"); this.carryPosition = transform.Find("CarryPosition"); this.sensesCol = (Collider) transform.Find("Senses").GetComponent("Collider"); this.move = (AntMovement) transform.GetComponent("AntMovement"); this.rg = new RandomGenerator(); this.nestThreshold = normalRandom(this.qualityThreshMean, this.qualityThreshNoise); this.percievedQuality = float.MinValue; this.finishedRecruiting = false; //make sure the value is within contraints if(this.nestThreshold > 1) this.nestThreshold = 1; else if(this.nestThreshold < 0) this.nestThreshold = 0; //!passive ants assess nest as a soon as simulation begins this.nextAssesment = Time.timeSinceLevelLoad; }