public GameRuleEventHappenedCondition(GameRuleEventType et, System.Type st, System.Type tt, string p)
    {
        eventType = et;
        param = p;
        sourceType = st;
        targetType = tt;

        //any event originating from a ball needs a ball
        //ideally it doesn't need to be holdable, but at the moment for practical reasons it does
        bool sourceIsBall = GameRules.derivesFrom(sourceType, typeof(Ball));
        if (sourceIsBall)
            requiredObjectForSource = new GameRuleRequiredObject(GameRuleRequiredObjectType.HoldableBall, null);
        //our event type doesn't have a required object as its source
        else
            requiredObjectForSource = null;

        //ball-ball collision needs a second ball
        if (sourceIsBall && GameRules.derivesFrom(targetType, typeof(Ball)))
            requiredObjectForTarget = new GameRuleRequiredObject(GameRuleRequiredObjectType.SecondBall, null);
        //any event that involves a player holding a ball requires a holdable ball
        else if (eventType == GameRuleEventType.Kick ||
            eventType == GameRuleEventType.Grab)
            requiredObjectForSource = new GameRuleRequiredObject(GameRuleRequiredObjectType.HoldableBall, null);
        //any field object collision that isn't with a boundary is with a goal
        else if (targetType == typeof(FieldObject) && param != "boundary")
            requiredObjectForTarget = new GameRuleRequiredObject(GameRuleRequiredObjectType.SpecificGoal, param);
        //our event type doesn't need have a required object as its target
        else
            requiredObjectForTarget = null;
    }
 public GameRuleZoneCondition(GameRuleRequiredObject zt, GameRuleSourceSelector s)
 {
     zoneType = zt;
     selector = s;
 }
Example #3
0
 public GameObject getPrefabForRequiredObject(GameRuleRequiredObject requiredObject)
 {
     if (requiredObject == GameRuleRequiredObject.Ball)
         return ballPrefab;
     else if (requiredObject == GameRuleRequiredObject.SecondBall)
         return bigBallPrefab;
     else if (requiredObject == GameRuleRequiredObject.FootGoal)
         return goalPrefab;
     else if (requiredObject == GameRuleRequiredObject.GoalPosts)
         return goalPrefab2;
     else if (requiredObject == GameRuleRequiredObject.BackboardHoop)
         return goalPrefab3;
     else if (requiredObject == GameRuleRequiredObject.SmallWall)
         return goalPrefab4;
     else if (requiredObject == GameRuleRequiredObject.FullGoalWall)
         return goalPrefab5;
     else if (requiredObject > GameRuleRequiredObject.ZoneTypeStart && requiredObject < GameRuleRequiredObject.ZoneTypeEnd)
         return zonePrefab;
     else
         throw new System.Exception("Bug: Invalid required object " + requiredObject);
 }
 public GameObject getPrefabForRequiredObject(GameRuleRequiredObject requiredObject)
 {
     GameRuleRequiredObjectType requiredObjectType = requiredObject.requiredObjectType;
     if (requiredObjectType == GameRuleRequiredObjectType.AnyBall || requiredObjectType == GameRuleRequiredObjectType.SecondBall)
         return ballSpawnableObjects[Random.Range(0, ballSpawnableObjects.Length)].spawnedObject;
     else if (requiredObjectType == GameRuleRequiredObjectType.HoldableBall)
         return holdableBallSpawnableObjects[Random.Range(0, holdableBallSpawnableObjects.Length)].spawnedObject;
     else if (requiredObjectType == GameRuleRequiredObjectType.BoomerangZone)
         return GameRules.instance.zonePrefab;
     //it's a specific object, get it from the registry
     else
         return findGoalObject(requiredObject.sportName).spawnedObject;
 }
 public GameRuleZoneCondition(GameRuleRequiredObjectType zt, GameRuleSourceSelector s)
 {
     zoneType = new GameRuleRequiredObject(zt, null);
     selector = s;
 }