private void Awake() { anim = gameObject.GetComponent <Animator>(); sprite_render = GetComponent <SpriteRenderer>(); // Cap quyen chinh cac thuoc tinh trong spriteReader pointscore = GameObject.FindGameObjectWithTag("Point").GetComponent <PointScore>(); // Important }
// Start is called before the first frame update void Start() { r2 = gameObject.GetComponent <Rigidbody2D>(); // Lay het cac thanh phan trong Rigidbody2D de co quyen truy xuat anim = gameObject.GetComponent <Animator>(); sprite_render = GetComponent <SpriteRenderer>(); // Cap quyen chinh cac thuoc tinh trong spriteReader pointscore = GameObject.FindGameObjectWithTag("Point").GetComponent <PointScore>(); attack = GameObject.Find("AttackTrigger").GetComponent <AttackTrigger>(); sm = GameObject.FindGameObjectWithTag("Sound").GetComponent <SoundManager>(); OurHeart = MaxHeart; }
void Start() { sounds = GameObject.FindGameObjectWithTag("Sound").GetComponent <SoundManager>(); pointScore = GameObject.FindGameObjectWithTag("Point").GetComponent <PointScore>();// Important anim = GetComponent <Animator>(); startPos = transform.localPosition; endPos = PosB.localPosition; nextPos = endPos; StartCoroutine(Spawner()); }
void Start() { pointscore = GameObject.FindGameObjectWithTag("Point").GetComponent <PointScore>();// Important sounds = GameObject.FindGameObjectWithTag("Sound").GetComponent <SoundManager>(); }
/* * 获得对于 'c' 类型棋,最好的下一步落点 * chessBoard : 当前局面 * c : 己方棋子类型 * cc : 对方棋子类型 converse char * level 难度级别 */ public static Point GetBestPoint(char[,] chessBoard, char c, char cc, int level) { Point point = new Point(0, 0); //存储己方最高分数位置 Point cPoint = new Point(0, 0); //存储对方最高分数位置 int maxScore = 0; //存储己方最高分数 int cMaxScore = 0; //对方最高分数 int row, column; //代表位置的行,列 int i = 0; PointScore[] scores = new PointScore[ROW_COUNT * COLUMN_COUNT]; //存储己方每个位置的得分 PointScore[] cScores = new PointScore[ROW_COUNT * COLUMN_COUNT]; //存储对方每个位置的得分 for (int j = 0; j < ROW_COUNT * COLUMN_COUNT; ++j) //初始化 { scores[j] = new PointScore(); cScores[j] = new PointScore(); } //获得己方分数 //加入随机数,随机方向,防止被套路,有得到的分数相等的情况 Random.seed = (int)Time.time; bool var1 = Random.value > 0.5; if (var1) { row = 0; } else { row = ROW_COUNT - 1; } for ( ; var1?row < ROW_COUNT : row >= 0;) { Random.seed = (int)Time.time; bool var2 = Random.value > 0.5; if (var2) { column = 0; } else { column = COLUMN_COUNT - 1; } for ( ; var2?column < COLUMN_COUNT : column >= 0;) { scores[i].x = row; scores[i].y = column; if ((int)chessBoard[row, column] == 0) //没有棋子 { scores[i].score = GetScoreAtPoint(chessBoard, c, row, column, level); //获得该位置得分 if (scores[i].score > maxScore) { maxScore = scores[i].score; //保存当前最高分,及位置 point.x = row; point.y = column; } ++i; } else //有棋子 { scores[i++].score = 0; } if (var2) { ++column; } else { --column; } } if (var1) { ++row; } else { --row; } } //获得对方分数 i = 0; Random.seed = (int)Time.time; var1 = Random.value > 0.5; if (var1) { row = 0; } else { row = ROW_COUNT - 1; } for ( ; var1?row < ROW_COUNT : row >= 0;) { Random.seed = (int)Time.time; bool var2 = Random.value > 0.5; if (var2) { column = 0; } else { column = COLUMN_COUNT - 1; } for ( ; var2?column < COLUMN_COUNT : column >= 0;) { cScores[i].x = row; cScores[i].y = column; if ((int)chessBoard[row, column] == 0) //没有棋子 { cScores[i].score = GetScoreAtPoint(chessBoard, cc, row, column, level); //获得该位置得分 if (cScores[i].score > cMaxScore) { cMaxScore = cScores[i].score; //保存当前最高分,及位置 cPoint.x = row; cPoint.y = column; } ++i; } else //有棋子 { cScores[i++].score = 0; } if (var2) { ++column; } else { --column; } } if (var1) { ++row; } else { --row; } } if (level == 1) { if (cMaxScore > maxScore) //防御 { point.x = cPoint.x; point.y = cPoint.y; } } else if (level > 1) //难度>1 { ArrayList maxScoreList = new ArrayList(); //己方得分最高集合 ArrayList cMaxScoreList = new ArrayList(); //对方得分最高集合 ArrayList resultList = new ArrayList(); //存放结果点 for (int m = 0; m < ROW_COUNT * COLUMN_COUNT; ++m) { if (scores[m].score == maxScore) { maxScoreList.Add(scores[m]); } if (cScores[m].score == cMaxScore) { cMaxScoreList.Add(cScores[m]); } } //Debug.Log("max: "+maxScoreList.Count+"cMax: "+cMaxScoreList.Count); if (cMaxScore > maxScore) //用cMaxScoreList 中的点 // for( int n = 0;n<maxScoreList.Count;++n){//攻防兼备 // for( int l = 0;l<cMaxScoreList.Count;++l){ // if(((PointScore)cMaxScoreList[l]).x == ((PointScore)maxScoreList[n]).x && ((PointScore)cMaxScoreList[l]).y == ((PointScore)maxScoreList[n]).y){ // resultList.Add(maxScoreList[n]); // break; // } // } // } // if(resultList.Count > 0){ // point = GetClosePoint(chessBoard,resultList); // }else{ { point = GetClosePoint(chessBoard, cMaxScoreList); // } } else if (cMaxScore <= maxScore) //进攻,用maxScoreList中的点 // for( int n = 0;n<cMaxScoreList.Count;++n){//攻防兼备 // for( int l = 0;l<maxScoreList.Count;++l){ // if(((PointScore)maxScoreList[l]).x == ((PointScore)cMaxScoreList[n]).x && ((PointScore)maxScoreList[l]).y == ((PointScore)cMaxScoreList[n]).y){ // resultList.Add(cMaxScoreList[n]); // break; // } // } // } // if(resultList.Count > 0){ // point = GetClosePoint(chessBoard,resultList); // }else{ { point = GetClosePoint(chessBoard, maxScoreList); // } } } return(point); }
void Start() { pointscore = GameObject.FindGameObjectWithTag("Point").GetComponent <PointScore>(); }
void Start() { mybody = gameObject.GetComponent <Rigidbody2D>(); knight = GameObject.FindGameObjectWithTag("Player").GetComponent <Knight>(); pointScore = GameObject.FindGameObjectWithTag("Point").GetComponent <PointScore>();// Important }