public override bool checkProceduralPrecondition(GameObject enemy) { wC = GetComponent <WorldCondition>(); lbr = GetComponent <Labourer> (); agent = GetComponent <NavMeshAgent>(); mts = GetComponent <menuju_tempat_sembunyi>(); // salah sasaran untuk index mis = GameObject.Find("enemy").GetComponent <misc> (); //timerM = lbr.timer; return(true); }
void Awake() { if (Instance == null) { Instance = this; Instance.Init(); } else { DestroyImmediate(this.gameObject); return; } DontDestroyOnLoad(this.gameObject); }
public override bool checkProceduralPrecondition(GameObject enemy) { lbr = GetComponent <Labourer> (); navComponent = GetComponent <NavMeshAgent> (); wC = GetComponent <WorldCondition> (); mis = GameObject.Find("enemy").GetComponent <misc> (); fs = GameObject.Find("player").GetComponent <FirstPersonController> (); timerM = 10f; target = mis.tempat_sembunyi [lbr.tampung].transform; wC.simpan = target; return(target != null); }
public bool testVaild( WorldCondition worldCond , int idxExpr ) { return exprList[idxExpr].testVaild(worldCond); }
public void generateVaild(System.Random rand, WorldCondition worldCond, int numExpr) { int idx = 0; exprList = new CondExpression[numExpr]; bool[] useExprMap = Utility.makeRandBool(rand, TotalExprNum, numExpr); for( int i = 0 ; i < TotalExprNum ; ++i ) { if (useExprMap[i] == false) continue; CondExpression expr = CreateExpression(i); if (expr!=null) { expr.generateVaild(rand, worldCond); } exprList[idx] = expr; ++idx; } bVaild = true; }
public override bool testVaild(WorldCondition worldCond) { return ( ( 1 << elements[0].meta ) & worldCond.valuePropertyFlag ) != 0; }
public override void generateVaild(System.Random rand, WorldCondition worldCond) { List<int> props = new List<int>(); for (int i = 0; i < (int)ValueProperty.Num; ++i ) { if ( ( (1 << i) & worldCond.valuePropertyFlag ) != 0 ) props.Add(i); } elements = new CondExprElement[1]; elements[0].type = CondExprElemntType.IntValue; elements[0].meta = props[ rand.Next() % props.Count ]; }
public override bool testVaild(WorldCondition worldCond) { if (IdxContent == 0) { return worldCond.isTopFireLighting((WallName)elements[1].meta, (CondDir)elements[0].meta, elements[2].meta != 0); } else { return elements[0].meta == worldCond.getTopFireLightingNum(); } }
public override void generateVaild(System.Random rand, WorldCondition worldCond) { elements = new CondExprElement[2]; elements[0].type = CondExprElemntType.IntValue; elements[0].meta = rand.Next() % objectMap.Length; elements[1].type = CondExprElemntType.Color; elements[1].meta = (int)worldCond.getObjectColor(objectMap[elements[0].meta]); }
public override bool testVaild(WorldCondition worldCond) { return elements[1].meta == worldCond.getObjectNum((ObjectId)elements[0].meta); }
public override bool testVaild( WorldCondition worldCond) { if (IdxContent == 0) { return worldCond.checkVaild((WallName)elements[0].meta, (WallName)elements[1].meta, (CondDir)elements[2].meta); } else { CondDir dir = (CondDir)elements[4].meta; int curIdx = worldCond.getWallIndex((WallName)elements[0].meta); for (int i = 1; i < 4; ++i) { int nextIdx = worldCond.getRelDirWallIndex( curIdx , dir ); if (nextIdx != worldCond.getWallIndex((WallName)elements[0].meta)) return false; } return true; } }
public override bool testVaild(WorldCondition worldCond) { if (IdxContent == 0) { int idx = worldCond.getWallIndex((WallName)elements[1].meta); if (elements[0].meta == 0) { idx = (idx + 2) % 4; } return elements[2].meta == (int)worldCond.wall[idx].color; } return false; }
public override void generateVaild(System.Random rand, WorldCondition worldCond) { //IdxContent = rand.Next() % 2; IdxContent = 0; if (IdxContent == 0) { elements = new CondExprElement[3]; elements[0].type = CondExprElemntType.FaceFront; elements[0].meta = rand.Next() % 2; elements[1].type = CondExprElemntType.WallName; elements[1].meta = rand.Next() % 4; int idx = worldCond.getWallIndex((WallName)elements[1].meta); idx = worldCond.getRelDirIndex(idx, CondDir.Front, elements[0].meta != 0); elements[2].type = CondExprElemntType.Color; elements[2].meta = (int)worldCond.wall[idx].color; } else { elements = new CondExprElement[3]; elements[0].type = CondExprElemntType.FaceFront; elements[0].meta = rand.Next() % 2; elements[1].type = CondExprElemntType.WallName; elements[1].meta = rand.Next() % 4; int idx = worldCond.getWallIndex((WallName)elements[1].meta); idx = worldCond.getRelDirIndex(idx, CondDir.Front, elements[0].meta != 0); elements[3].type = CondExprElemntType.Dir; if ( (rand.Next() % 2 ) == 0 ) elements[3].meta = (int)CondDir.Left; else elements[3].meta = (int)CondDir.Right; elements[4].type = CondExprElemntType.IntValue; elements[4].meta = 1 + (rand.Next() % 3); elements[2].type = CondExprElemntType.Color; elements[2].meta = (int)worldCond.wall[idx].color; } }
public virtual void generateVaild(System.Random rand, WorldCondition worldCond) { }
public virtual bool testVaild( WorldCondition worldCond){ return false; }
public override void generateVaild(System.Random rand, WorldCondition worldCond) { IdxContent = rand.Next() % 2; if (IdxContent == 0) { elements = new CondExprElement[3]; elements[0].type = CondExprElemntType.FaceFront; elements[0].meta = rand.Next() % 2; elements[2].type = CondExprElemntType.Dir; elements[2].meta = (int)dirMap[ rand.Next() % dirMap.Length ]; List<int> idxLighting = new List<int>(); for (int i = 0; i < 4; ++i ) { if ( worldCond.isTopFireLighting(i) ) { idxLighting.Add(i); } } int idx = idxLighting[rand.Next() % idxLighting.Count]; if (idx == 0) idx += 2; elements[1].type = CondExprElemntType.WallName; elements[1].meta = (int)worldCond.wall[ ( idx - elements[2].meta + 4 ) % 4 ].name; } else { elements = new CondExprElement[1]; elements[0].type = CondExprElemntType.IntValue; elements[0].meta = worldCond.getTopFireLightingNum(); } }
public void generateRandom(System.Random rand, WorldCondition worldCond, int numExpr, int numInvaild) { bool[] invaildMap = Utility.makeRandBool(rand, TotalExprNum, numInvaild); bool[] useExprMap = Utility.makeRandBool(rand, TotalExprNum, numExpr ); int idx = 0; exprList = new CondExpression[numExpr]; for (int i = 0; i < TotalExprNum; ++i) { if (useExprMap[i] == false) continue; CondExpression expr = CreateExpression(i); if (expr != null) { if ( invaildMap[i] ) { do { expr.generate(rand); } while (expr.testVaild(worldCond) == true); } else { expr.generateVaild( rand , worldCond ); } } exprList[idx] = expr; ++idx; } bVaild = false; }
// Use this for initialization public void spawnScene( WorldCondition worldCond ) { colorSet = new Color[6]; colorSet[0] = Color.red; colorSet[1] = Color.yellow; colorSet[2] = Color.green; colorSet[3] = Color.blue; colorSet[4] = Color.black; colorSet[5] = Color.white; //Wall List - 4 Wall; List<GameObject> Wall = new List<GameObject>(4); //generate parameters for setting Wall colors Parameter_List = GenerateNumber(4, 6); number_of_item = GenerateNumber(4, 10); for (int i = 0; i < worldCond.objects.Count; ++i ) { ObjectInfo info = worldCond.objects[i]; for (int n = 0 ; n < info.num ; ++n ) { switch (info.id) { case ObjectId.Ball: Instantiate(Prefab_Ball, new Vector3(Random.Range(-display_range, display_range), 0, Random.Range(-display_range, display_range)), Quaternion.identity); break; case ObjectId.Candlestick: Instantiate(Prefab_Candle, new Vector3(Random.Range(-display_range, display_range), 0, Random.Range(-display_range, display_range)), Quaternion.identity); break; case ObjectId.Book: Instantiate(Prefab_Book, new Vector3(Random.Range(-display_range, display_range), 0, Random.Range(-display_range, display_range)), Quaternion.identity); break; case ObjectId.Doll: Instantiate(Prefab_Doll, new Vector3(Random.Range(-display_range, display_range), 0, Random.Range(-display_range, display_range)), Quaternion.identity); break; } } } for (int i = 0; i < 4; ++i ) { WallInfo info = worldCond.wall[i]; switch(info.name) { case WallName.Number: Wall.Add(Instantiate(Prefab_Wall_Number) as GameObject); break; case WallName.Door: Wall.Add(Instantiate(Prefab_Wall_Door) as GameObject); break; case WallName.Clock: Wall.Add(Instantiate(Prefab_Wall_Clock) as GameObject); break; case WallName.Bed: Wall.Add(Instantiate(Prefab_Wall_Bed) as GameObject); break; } } //To creat 4 Wall; Wall[0].transform.position = new Vector3(0, 25, 25); Wall[0].GetComponent<MeshRenderer>().material.color = colorSet[ (int)worldCond.wall[0].color ]; Wall[1].transform.position = new Vector3(-25, 25, 0); Wall[1].transform.Rotate(new Vector3(0, 90, 0)); Wall[1].GetComponent<MeshRenderer>().material.color = colorSet[(int)worldCond.wall[1].color]; Wall[2].transform.position = new Vector3(0, 25, -25); Wall[2].GetComponent<MeshRenderer>().material.color = colorSet[(int)worldCond.wall[2].color]; Wall[3].transform.position = new Vector3(25, 25, 0); Wall[3].transform.Rotate(new Vector3(0, 90, 0)); Wall[3].GetComponent<MeshRenderer>().material.color = colorSet[(int)worldCond.wall[3].color]; }
public void generate( System.Random rand , WorldCondition worldCond , int numSel , int numExpr , int numVaild ) { numSelection = numSel; numConditionVaild = numVaild; conditions = new Condition[numSelection]; int[] objectIdMap = Utility.makeRandSeq( rand , 6 , 0 ); bool[] vaildMap = Utility.makeRandBool( rand , numSelection , numConditionVaild ); for( int i = 0 ; i < numSelection ; ++i ) { conditions[i] = new Condition(); if ( vaildMap[i] ) { int numInvaild = 1; int additionInvaild = numExpr - 1; if (additionInvaild > 0) numInvaild += rand.Next() % additionInvaild; conditions[i].generateRandom(rand, worldCond, numExpr, numInvaild ); } else { conditions[i].generateVaild( rand , worldCond , numExpr ); } conditions[i].targetId = (ObjectId)objectIdMap[i]; } }
public override bool testVaild(WorldCondition worldCond) { return elements[1].meta == (int)worldCond.getObjectColor(objectMap[elements[0].meta]); }
public override void generateVaild(System.Random rand, WorldCondition worldCond) { elements = new CondExprElement[2]; elements[0].type = CondExprElemntType.Object; elements[0].meta = rand.Next() % (int)ObjectId.NumCondObject; elements[1].type = CondExprElemntType.IntValue; elements[1].meta = worldCond.getObjectNum((ObjectId)elements[0].meta); }
public override void generateVaild(System.Random rand , WorldCondition worldCond ) { IdxContent = rand.Next() % 2; if (IdxContent == 0) { elements = new CondExprElement[3]; elements[0].type = CondExprElemntType.WallName; elements[0].meta = rand.Next()%4; elements[2].type = CondExprElemntType.Dir; elements[2].meta = (int)dirMap[rand.Next() % 2]; elements[1].type = CondExprElemntType.WallName; elements[1].meta = (int)worldCond.getRelDirWall( (WallName)elements[0].meta , (CondDir)elements[2].meta ); } else { elements = new CondExprElement[5]; int idx = rand.Next() % 4; CondDir dir = dirMap[rand.Next() % 2]; elements[4].type = CondExprElemntType.Dir; elements[4].meta = (int)dir; for( int i = 0 ; i < 4 ; ++i ) { elements[i].type = CondExprElemntType.WallName; elements[i].meta = (int)worldCond.wall[idx].name; idx = worldCond.getRelDirWallIndex(idx, dir); } } }