Exemplo n.º 1
0
    private void OnGameBuilt(object sender)
    {
        floatingObject = GetComponent <FloatingObject>();

        powerController = GetComponent <PowerController>();
        powerController.EventPowerAttached += OnEventPowerAttached;

        game = GameObject.FindGameObjectWithTag(Tags.Game).GetComponent <Game>();
        game.EventShipEliminated += OnShipEliminated;
        game.EventEnd            += OnEventEnd;

        // Listen all event fights
        foreach (GameObject ship in game.ShipsInGame)
        {
            TailController tailController = ship.GetComponent <TailController>();
            tailController.OnEventFight += OnEventFight;
        }

        gameObject.GetComponent <Tail>().OnEventOrbAttached += OnEventOrbAttached;
        // Attaching field of view notification
        GetComponentInChildren <AIFieldOfView>().EventOnFieldOfViewEnter += OnFieldOfViewEnter;
        checkpoints = new HashSet <GameObject>(GameObject.FindGameObjectsWithTag(Tags.AICheckpoint));


        gameBuilt = true;
    }
Exemplo n.º 2
0
    void Awake()
    {
        //Everyone have a tail
        gameObject.AddComponent <Tail>();
        PowerController powerController = gameObject.AddComponent <PowerController>();

        //Server side controls the collisions
        if (NetworkHelper.IsServerSide())
        {
            TailController tail_controller = gameObject.AddComponent <TailController>();

            tail_controller.GetOffenceDriverStack().Push(new DefaultOffenceDriver(offence));
            tail_controller.GetDefenceDriverStack().Push(new DefaultDefenceDriver(defence));
            tail_controller.GetAttacherDriverStack().Push(new DefaultAttacherDriver());
            tail_controller.GetDetacherDriverStack().Push(new DefaultDetacherDriver());
        }

        //Client side controls the movement
        if (NetworkHelper.IsOwnerSide(networkView))
        {
            MovementController movement_controller = gameObject.AddComponent <MovementController>();

            movement_controller.enabled = false;

            movement_controller.GetEngineDriverStack().Push(new DefaultEngineDriver(speed));
            movement_controller.GetWheelDriverStack().Push(new DefaultWheelDriver(steering));
        }
    }
Exemplo n.º 3
0
    protected override void ActivateServer()
    {
        tailControllers = new List <TailController>();

        foreach (GameObject ship in GameObject.FindGameObjectWithTag(Tags.Game).GetComponent <Game>().ShipsInGame)
        {
            TailController tailController = ship.GetComponent <TailController>();
            tailController.OnEventFight += eventLogger_EventFight;
            tailControllers.Add(tailController);
        }
    }
Exemplo n.º 4
0
    private void CleanAI()
    {
        game.EventShipEliminated -= OnShipEliminated;
        game.EventEnd            -= OnEventEnd;

        // Remove all event fights
        foreach (GameObject ship in game.ShipsInGame)
        {
            TailController tailController = ship.GetComponent <TailController>();
            tailController.OnEventFight -= OnEventFight;
        }

        gameObject.GetComponent <Tail>().OnEventOrbAttached -= OnEventOrbAttached;
        // Attaching field of view notification
        //GetComponentInChildren<AIFieldOfView>().EventOnFieldOfViewEnter -= OnFieldOfViewEnter;
    }
Exemplo n.º 5
0
    void SpawnPrefab(Note note, Transform prefab, Vector3 point)
    {
        Transform noteTransform = Instantiate(prefab);

        noteTransform.SetParent(transform);
        noteTransform.position = new Vector3(prefab.position.x, prefab.position.y, point.z);
        Transform noteCollider = noteTransform.GetChild(0);

        //noteCollider.gameObject.AddComponent<NoteController>();
        noteCollider.GetComponent <NoteController>().InitializeNote(note, false);
        if (note.secLength > 0) // There's a held note, so spawn a 'tail' on the note
        {
            Transform tail      = Instantiate(_tailPrefab);
            Color     tailColor = noteTransform.gameObject.GetComponentInChildren <Renderer>().material.color;
            tail.GetComponentInChildren <Renderer>().material.color = tailColor;

            tail.SetParent(noteTransform.transform);
            // We want to push the tail back by half to line up with the end of the note
            tail.position = new Vector3(noteTransform.position.x, noteTransform.position.y,
                                        noteTransform.position.z + (note.secLength / 2f) + (tail.localScale.z / 2f));
            // Then we reshape our prefab to make a tail of the correct Length
            // First we handle the collider
            Transform tailCollider = tail.GetChild(0);
            tailCollider.localScale    = new Vector3(tail.localScale.x, tail.localScale.y, 0.5f + note.secLength);
            tailCollider.localPosition = new Vector3(tailCollider.localPosition.x, tailCollider.localPosition.y, tailCollider.localPosition.z + 0.25f);
            // Then we shrink the renderer (to make it thinner)
            Transform tailRenderer = tail.GetChild(1);
            tailRenderer.localScale += new Vector3(-tail.localScale.x * 0.5f, -tail.localScale.y * 0.5f, note.secLength);
            Destroy(tailCollider.gameObject.GetComponent <NoteController>());
            TailController tc = tailCollider.gameObject.AddComponent <TailController>();
            tc.InitializeNote(note, true);
            noteCollider.GetComponent <NoteController>().AttachTail(tc);
            tail.SetParent(noteTransform.GetChild(2)); // Attach to tail spawn point
        }
        if (noteTransform.position.z < Camera.main.farClipPlane)
        {
            foreach (Renderer r in noteTransform.GetComponentsInChildren <Renderer>())
            {
                r.enabled = true;
            }
        }
    }
Exemplo n.º 6
0
 public TailPart(GameObject gameObject)
 {
     this.gameObject = gameObject;
     controller      = gameObject.GetComponent <TailController>();
 }
Exemplo n.º 7
0
    // Start contains code initializing the script variables, and is called before the first frame
    void Start()
    {
        // Default speed is 10. speedDelta is 0 to ensure start speed is 0
        speed      = 10;
        speedDelta = 0;
        speedLimit = 146;

        PlayerPrefs.SetInt("Score", 0);

        // Initialize tail with reference to Tail GameObject, then get components with this reference
        tail           = GameObject.Find("Tail");
        tailController = tail.GetComponent <TailController>();
        playerAnim     = tail.GetComponent <Animator>();

        // Get SplashController components of both splash objects, to use their methods to set splash positions
        splash1           = GameObject.Find("Splash1");
        splash2           = GameObject.Find("Splash2");
        splashController1 = splash1.GetComponent <SplashController>();
        splashController2 = splash2.GetComponent <SplashController>();

        // Again, get object reference followed by object component
        scoreDetails         = GameObject.Find("ScoreDetails");
        trickTrackController = scoreDetails.GetComponent <TrickTrackController>();

        degrees = 0;
        degInc  = 6;

        // Set acceleration and lenience based on difficulty
        difficulty = PlayerPrefs.GetInt("Difficulty");
        switch (difficulty)
        {
        case 0:
            speedInc           = 12;
            entryAngleLenience = 15;
            PlayerPrefs.SetFloat("end_multiplier", 1);
            break;

        case 1:
            speedInc           = 10;
            entryAngleLenience = 35;
            break;

        case 2:
            speedInc           = 8;
            entryAngleLenience = 25;
            break;

        case 3:
            speedInc           = 6;
            entryAngleLenience = 15;
            break;

        case 4:
            speedInc           = 5;
            entryAngleLenience = 10;
            break;
        }

        spaceObjects = new bool[10];

        // Values for sea and sand boundary, and gravity
        gravConst = 0.3f;
        seaLevel  = 20.5f;
        sandLevel = -44f;

        // Timer set to 25 so acceleration occurs at beginning
        timer          = 25;
        maxTimer       = 75;
        enterTimerSet1 = 5;
        enterTimerSet2 = 10;

        leftTouched  = false;
        rightTouched = false;

        // Set all audio source variables to AudioSource components of respective GameObjects
        splash_source         = GameObject.Find("Inside_Splash").GetComponent <AudioSource>();
        outside_splash_source = GameObject.Find("Outside_Splash").GetComponent <AudioSource>();
        underwater_ambience   = GameObject.Find("Underwater_Ambience").GetComponent <AudioSource>();
        outside_ambience      = GameObject.Find("Outside_Ambience").GetComponent <AudioSource>();
        space_ambience        = GameObject.Find("Space_Ambience").GetComponent <AudioSource>();

        outside_ambience.Play();
        outside_ambience.volume = 0;
    }
Exemplo n.º 8
0
 public void AttachTail(TailController addedTail)
 {
     Tail = addedTail;
 }