示例#1
0
    public CS_Prop_SpawnArea GetLargestSpawnArea(CS_Prop_SpawnArea.Type g_type = CS_Prop_SpawnArea.Type.Object)
    {
        List <CS_Prop_SpawnArea> t_areaList;

        switch (g_type)
        {
        case CS_Prop_SpawnArea.Type.Player:
            t_areaList = mySpawnAreaList_Player;
            break;

        default:
            t_areaList = mySpawnAreaList_Object;
            break;
        }
        if (t_areaList == null || t_areaList.Count == 0)
        {
            return(mySpawnArea_Default);
        }

        CS_Prop_SpawnArea t_largest = t_areaList [0];

        for (int i = 0; i < t_areaList.Count; i++)
        {
            if (t_areaList [i].GetSize() > t_largest.GetSize())
            {
                t_largest = t_areaList [i];
            }
        }
        return(t_largest);
    }
示例#2
0
            public override bool Init(CS_RuleSet g_ruleSet)
            {
                if (!base.Init(g_ruleSet))
                {
                    return(false);
                }

                if (myRuleInfo.isTeamBased == false)
                {
                    Debug.LogError(this.gameObject.name + " need to be TeamBased!");
                }

                if (myRuleInfo.myScoreType != ScoreType.Trigger)
                {
                    Debug.LogError(this.gameObject.name + " need to be Trigger!");
                }

                //find spawn area
                mySpawnArea = CS_GameManager.Instance.GetRandomSpawnArea();

                //find goal
                myGoalPrefab = CS_EverythingManager.Instance.GetRandomPrefab(Constants.NAME_PROP_GOAL);

                //check if is special goal size
                float t_specialSize = -1;

                foreach (SpecialGoalSize f_setting in mySpecialGoalSize)
                {
                    if (f_setting.prefab == myGoalPrefab)
                    {
                        t_specialSize = f_setting.size;
                    }
                }

                //create goals accoring to team count
                for (int i = 0; i < CS_PlayerManager.Instance.GetTeamCount(); i++)
                {
                    GameObject f_goal = Instantiate(myGoalPrefab, CS_EverythingManager.Instance.transform) as GameObject;
                    f_goal.GetComponent <CS_Prop_Goal> ().AddRule(this);
                    if (t_specialSize == -1)
                    {
                        f_goal.transform.localScale = f_goal.transform.localScale * myGoalSize;
                    }
                    else
                    {
                        f_goal.transform.localScale = f_goal.transform.localScale * t_specialSize;
                    }
                    //add goal to the list
                    myGoals.Add(f_goal);
                }


                Vector3[] t_positions = mySpawnArea.GetRandomPoints(myGoals.Count);

                //move the goal and look at center
                for (int i = 0; i < myGoals.Count; i++)
                {
                    myGoals [i].transform.position = t_positions [i];
                    myGoals [i].transform.LookAt(mySpawnArea.transform.position);
                }

//				if (CS_Map.Instance != null && CS_Map.Instance.GetSpawnPositions ().Count >= CS_GameManager.Instance.GetTeamCount ()) {
//					Debug.Log ("using CS_Map!");
//					for (int i = 0; i < myGoals.Count; i++) {
//						Vector3 t_position = CS_Map.Instance.GetSpawnPositions () [i].position;
//						t_position = new Vector3 (t_position.x, 0, t_position.z);
//						myGoals [i].transform.position = t_position + Vector3.up * Constants.DISTANCE_INIT_HEIGHT;
//						myGoals [i].transform.LookAt (Vector3.up * Constants.DISTANCE_INIT_HEIGHT);
//					}
//				} else {
//					//calculate the angle for each goal
//					float t_baseAngle = Random.Range (0, 360f);
//					float t_deltaAngle = 360f / CS_GameManager.Instance.GetTeamCount ();
//
//					//move the goal and look at center
//					for (int i = 0; i < myGoals.Count; i++) {
//						myGoals [i].transform.position =
//						Quaternion.AngleAxis (t_baseAngle + t_deltaAngle * i, Vector3.up) * Vector3.forward * myGoalDistanceToCenter +
//						Vector3.up * Constants.DISTANCE_INIT_HEIGHT;
//						myGoals [i].transform.LookAt (Vector3.up * Constants.DISTANCE_INIT_HEIGHT);
//					}
//				}

                //find balls
                myBallPrefab = CS_EverythingManager.Instance.GetRandomPrefab(Constants.NAME_PROP_BALL);
                InitBall();

                return(true);
            }
示例#3
0
    // Use this for initialization
    void Start()
    {
        //create buttons
        for (int i = 0; i < 5; i++)
        {
            CreateButton(CS_Prop_Button.ButtonType.Continue, false);
            CreateButton(CS_Prop_Button.ButtonType.Quit, false);
        }

        //load map
        myMap = CS_AnyLevelSave.LoadFile(maps [Random.Range(0, maps.Length)]);
//		myMap = CS_AnyLevelSave.LoadFile (myMapName);
        if (myMap != null)
        {
            foreach (CS_AnyLevelSave_Object f_SaveObject in myMap.anyObjects)
            {
                GameObject t_prefab = CS_EverythingManager.Instance.GetAnyLevelPrefab(f_SaveObject.prefabName);

                GameObject        t_GameObject     = Instantiate(t_prefab, this.transform);
                CS_AnyLevelObject t_anyLevelObject = t_GameObject.GetComponent <CS_AnyLevelObject> ();

                //set name
                t_GameObject.name = f_SaveObject.name;

                //set transform
                t_GameObject.transform.position   = (Vector3)(f_SaveObject.position);
                t_GameObject.transform.localScale = (Vector3)(f_SaveObject.scale);
                t_GameObject.transform.rotation   = (Quaternion)(f_SaveObject.rotation);

                //set invisible
                if (t_anyLevelObject.GetMyCategory() == AnyBall.Editor.Category.Invisible)
                {
                    ((CS_AnyLevelObject_Invisible)t_anyLevelObject).Hide();
                }

                CS_Prop_SpawnArea t_spawnArea = t_GameObject.GetComponent <CS_Prop_SpawnArea> ();
                if (t_spawnArea != null)
                {
                    if (t_spawnArea.MySpawnType == CS_Prop_SpawnArea.Type.Player)
                    {
                        mySpawnAreaList_Player.Add(t_spawnArea);
                    }
                    else
                    {
                        mySpawnAreaList_Object.Add(t_spawnArea);
                    }
                }

                //remove the any level component
                Destroy(t_anyLevelObject);
            }
        }

//		//create score board
//		for (int i = 0; i < Constants.NUMBER_MAX_TEAM; i++) {
//			CS_ScoreBoard t_scoreBoard = Instantiate (myScoreBoardPrefab).GetComponent<CS_ScoreBoard> ();
//			myScoreBoards.Add (t_scoreBoard);
//
//            Vector3 t_position =
//                GetRandomSpawnArea ().GetRandomPoint ();
//
//			t_scoreBoard.Init (i, CS_PlayerManager.Instance.GetTeamColor (i), t_position);
//		}
//
//		//show and hide score board
//		for (int i = 0; i < myScoreBoards.Count; i++) {
//			if (CS_PlayerManager.Instance.IsTeamExist (i)) {
//				myScoreBoards [i].gameObject.SetActive (true);
//			} else {
//				myScoreBoards [i].gameObject.SetActive (false);
//			}
//		}

        //init game score
        myGameScore.Clear();
        for (int i = 0; i < CS_PlayerManager.Instance.GetTeamCount(); i++)
        {
            myGameScore.Add(0);
        }

        //init player position
        CS_PlayerManager.Instance.HidePlayerNotInUse();

        List <GameObject> t_players = CS_PlayerManager.Instance.MyPlayersInUse;

        for (int i = 0; i < t_players.Count; i++)
        {
            t_players [i].transform.position = GetRandomSpawnArea(CS_Prop_SpawnArea.Type.Player).GetRandomPoint();
        }

        CS_GameScoreBoard.Instance.InitScoreBoard(CS_PlayerManager.Instance.GetTeamCount(), myWinningScore);

        CS_GameScoreBoard.Instance.Hide();

        RoundStart();
    }
            public override bool Init(CS_RuleSet g_ruleSet)
            {
                if (!base.Init(g_ruleSet))
                {
                    return(false);
                }

                if (myRuleInfo.myScoreType != ScoreType.Trigger)
                {
                    Debug.LogError(this.gameObject.name + " need to be Trigger!");
                }


                //find goal
                myAreaPrefab = CS_EverythingManager.Instance.GetRandomPrefab(Constants.NAME_PROP_AREA);

                //check if is special goal size
                float t_specialSize = -1;

                foreach (SpecialGoalSize f_setting in mySpecialAreaSize)
                {
                    if (f_setting.prefab == myAreaPrefab)
                    {
                        t_specialSize = f_setting.size;
                    }
                }

                for (int i = 0; i < CS_PlayerManager.Instance.GetTeamCount(); i++)
                {
                    isPlayerOnHill.Add(0);
                    myPlayerOnHillTime.Add(0);
                }

                if (myRuleInfo.isTeamBased)
                {
                    //create goals accoring to team count
                    for (int i = 0; i < CS_PlayerManager.Instance.GetTeamCount(); i++)
                    {
                        GameObject f_goal = Instantiate(myAreaPrefab, CS_EverythingManager.Instance.transform) as GameObject;
                        f_goal.transform.rotation = Quaternion.identity;

                        CS_Prop_Area t_area = f_goal.GetComponentInChildren <CS_Prop_Area> ();
                        t_area.AddRule(this);
                        t_area.SetTeamNumber(i);
                        if (t_specialSize == -1)
                        {
                            f_goal.transform.localScale = f_goal.transform.localScale * myAreaSize;
                        }
                        else
                        {
                            f_goal.transform.localScale = f_goal.transform.localScale * t_specialSize;
                        }
                        //add goal to the list
                        myAreas.Add(t_area);
                    }

                    //move the goal and look at center
                    for (int i = 0; i < myAreas.Count; i++)
                    {
                        CS_Prop_SpawnArea t_area = CS_GameManager.Instance.GetRandomSpawnArea();
                        myAreas [i].transform.position = t_area.GetRandomPoint();
                        myAreas [i].transform.LookAt(t_area.transform.position);
                    }
                }
                else
                {
                    GameObject   f_goal = Instantiate(myAreaPrefab, CS_EverythingManager.Instance.transform) as GameObject;
                    CS_Prop_Area t_area = f_goal.GetComponentInChildren <CS_Prop_Area> ();
                    t_area.AddRule(this);
                    if (t_specialSize == -1)
                    {
                        f_goal.transform.localScale = f_goal.transform.localScale * myAreaSize;
                    }
                    else
                    {
                        f_goal.transform.localScale = f_goal.transform.localScale * t_specialSize;
                    }
                    //add goal to the list
                    myAreas.Add(t_area);
                }

                return(true);
            }