Пример #1
0
 public void AwakeLevel(GameManager currentGameManager)
 {
     InitializeVariables();
     storm     = FindObjectOfType <StormBehavior>();
     newCamera = FindObjectOfType <MultipleTargetCamera>();
     GetPlayersInitialLocation();
 }
Пример #2
0
    void Start()
    {
        playerHp  = GetComponent <HPManager>();
        rigidbody = GetComponent <Rigidbody>();
        states    = GetComponent <PlayerStates>();

        camera = GameObject.FindWithTag("Camera").GetComponent <MultipleTargetCamera>();
    }
    private void OnEnable()
    {
        if (Instance == null)
        {
            Instance = this;
        }

        if (targets == null)
        {
            targets = new List <Transform>();
        }
    }
Пример #4
0
    // Use this for initialization
    void Start()
    {
        // player starts at this position
        respawnPoint = transform.position;

        health         = MaxPlayerHealth;
        movement       = FindObjectOfType <Movement>();
        playerRenderer = gameObject.GetComponentInChildren <Renderer>();
        cam            = FindObjectOfType <MultipleTargetCamera>();

        //destroy the controller if the player is not controlled by me
        //   if (!photonView.IsMine && GetComponent<Movement>() != null)
        //    Destroy(GetComponent<Movement>());
    }
Пример #5
0
 void Start()
 {
     nowArea = 0;
     StartCoroutine(AreaEnumerator());
     timer = changeTime + 1;
     PlayerSpawn(AreaObject[0].transform.position);
     foreach (AIPlayer Aip in FindObjectsOfType <AIPlayer>())
     {
         Aip.AreaPos = AreaObject[0].transform.position;
     }
     foreach (PlayerMove Pm in FindObjectsOfType <PlayerMove>())
     {
         Pm.AreaPos = AreaObject[0].transform.position;
     }
     multipleCamera = FindObjectOfType <MultipleTargetCamera>();
 }
Пример #6
0
    private void Start()
    {
        //Initializes the score of each team
        teamScore      = new Dictionary <string, int>();
        teamScore["r"] = 0;
        teamScore["b"] = 0;
        teamScore["y"] = 0;
        teamScore["g"] = 0;

        //Finds the number timer
        numTime = GameObject.FindGameObjectWithTag("Timer").GetComponent <Text>();
        //Finds all peices of the Cherry Timer
        timer = GameObject.FindGameObjectWithTag("Cherry Timer");
        for (int x = 0; x <= 10; x++)
        {
            if (timer.transform.GetChild(x).gameObject.name != "Boom!")
            {
                timerChildren.Add(timer.transform.GetChild(x).gameObject);
            }

            else
            {
                boom = timer.transform.GetChild(x).gameObject;
            }
        }
        //Sets the multiple target camera
        mtc = multipleTargetCamera.GetComponent <MultipleTargetCamera>();

        //Find Leader Images for the leader board.
        lead = GameObject.FindGameObjectWithTag("Leader");
        for (int x = 0; x <= 15; x++)
        {
            leader.Add(lead.transform.GetChild(x).gameObject);
        }

        //Set up timer value
        _waitingTime = waitingTime;

        //Starts countdown
        StartCoroutine(StartCountdown());

        //Initial Game
        InitialGame();
    }
Пример #7
0
    void Update()
    {
        if (!cantMove)
        {
            if (Life > 0)
            {
                switch (playerState)
                {
                case PlayerState.OnIce:
                    StartCoroutine(IceEffect());
                    break;

                case PlayerState.OnImpulse:
                    ImpulseState();
                    break;

                case PlayerState.OnDash:
                    DashState();
                    break;

                case PlayerState.Normal:
                    NormalState();
                    break;

                case PlayerState.OnPosion:
                    StartCoroutine(PosionEffect());
                    PoisonState();
                    break;
                }
            }
            else
            {
                if (!defeat)
                {
                    MultipleTargetCamera.SetTargets(transform, 1);
                    AkSoundEngine.PostEvent("pl_lost", gameObject);
                    //GameManager.Get().SetPlayers(prefab);
                    DefeatPlayer(name, Enemy.name);
                    defeat = true;
                }
            }
        }
    }
Пример #8
0
    // Start is called before the first frame update
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        if (gameCamera == null)
        {
            gameCamera = GetComponentInChildren <Camera>();
        }
        bounds             = new Bounds();
        bounds             = SetBounds();
        transform.position = GetCenterPoint() + offset;
    }
Пример #9
0
    //Awake is always called before any Start functions

    void Awake()
    {
        cam = GameObject.FindObjectOfType <MultipleTargetCamera>();

        //Check if instance already exists
        if (GM == null)
        {
            //if not, set instance to this
            GM = this;
        }
        //If instance already exists and it's not this:
        else if (GM != this)
        {
            //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
            Destroy(gameObject);
        }
        //Sets this to not be destroyed when reloading scene
        //DontDestroyOnLoad(gameObject);
    }
Пример #10
0
    // Initialization
    void Awake()
    {
        inputJump       = "P" + controllerNumber + "Jump";
        inputSlide      = "P" + controllerNumber + "Slide";
        inputAction     = "P" + controllerNumber + "Action";
        inputHorizontal = "P" + controllerNumber + "Horizontal";
        inputVertical   = "P" + controllerNumber + "Vertical";

        spriteRenderer = GetComponent <SpriteRenderer>();
        animator       = GetComponent <Animator>();
        ipReference    = GetComponent <ItemPickup>();

        mainCamera       = GameObject.FindWithTag("MainCamera");
        mainCameraScript = (MultipleTargetCamera)mainCamera.GetComponent(typeof(MultipleTargetCamera));

        /*
         * main = GameObject.FindWithTag("GameController");
         * mainScript = (GM_Main)main.GetComponent(typeof(GM_Main));
         * players = mainScript.getPlayers();
         */
        gameModeReference = FindObjectOfType <GM_Main>();
    }
Пример #11
0
 private void Awake()
 {
     _camera = GetComponent <Camera>();
     _multipleTargetCamera = GetComponent <MultipleTargetCamera>();
 }
Пример #12
0
    void CameraAddPlayer(GameObject obj)
    {
        MultipleTargetCamera mtc = GameObject.Find("Camera").GetComponent <MultipleTargetCamera>();

        mtc.targets.Add(obj);
    }
Пример #13
0
    public static float FindNearestEnemyToLine(Transform self, CharacterController2D player)
    {
        MultipleTargetCamera mtc = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <MultipleTargetCamera>();

        string[]         joystickNames     = Input.GetJoystickNames();
        HashSet <string> joystickNamesList = new HashSet <string>(joystickNames);

        joystickNamesList.Remove("");
        if (joystickNamesList != null && joystickNamesList.Count > 0)
        {
            float horizontal = InputManager.GetAxis("JoystickHorizontal", player);
            float vertical   = InputManager.GetAxis("JoystickVertical", player);


            Vector3 rayOrigin    = self.position;
            Vector3 rayDirection = new Vector3(horizontal, vertical, 0f);
            rayDirection.Normalize();
            GameObject[] enemyObjects     = GameObject.FindGameObjectsWithTag("Enemy");
            Enemy[]      enemies          = new Enemy[enemyObjects.Length];
            Vector3      vectToEnemy      = Vector3.negativeInfinity;
            float        smallestDistance = float.PositiveInfinity;
            for (int i = 0; i < enemyObjects.Length; i++)
            {
                Enemy e = enemies[i] = enemyObjects[i].GetComponent <Enemy>();

                Vector3 point = e.transform.position;

                Vector3 vectorToEnemy = (point - self.position);
                vectorToEnemy.Normalize();

                Vector3 proj = Vector3.Project(vectorToEnemy, rayDirection);
                //Debug.Log("proj: " + proj);

                float dot = Vector3.Dot(rayDirection, vectorToEnemy);
                Debug.DrawRay(rayOrigin, 10 * rayDirection, Color.yellow);
                //Debug.Log("dot " + Vector3.Dot(rayDirection, vectorToEnemy));
                if (dot > .90)
                {
                    //snap to target
                    float dToEnemy = Mathf.Abs(e.transform.position.x - self.position.x);
                    //Debug.Log("dist to enemy: " + dToEnemy);
                    float distance = Vector3.Distance(rayOrigin, point);
                    float angle    = Vector3.Angle(rayDirection, point - rayOrigin);
                    float dist     = (distance * Mathf.Sin(angle * Mathf.Deg2Rad));
                    //Debug.Log("dist " + dist);
                    if (dToEnemy < 20 && dot * dToEnemy < smallestDistance)
                    {
                        vectToEnemy      = vectorToEnemy;
                        smallestDistance = dToEnemy;
                    }
                }
            }
            if (enemyObjects.Length == 0)
            {
            }
            _rightStickInputActive = Mathf.Abs(vertical) > 0.1f || Mathf.Abs(horizontal) > 0.1f;
            if (_rightStickInputActive)
            {
                _oldRightJoystickInputVector = new Vector2(horizontal, vertical);
                _oldRightJoystickInputVector.Normalize();
            }
            //mtc.offset = new Vector3 (_oldRightJoystickInputVector.x, _oldRightJoystickInputVector.y, -8);
            if (vectToEnemy.z > -10f)
            {
                //something was set

                return(Mathf.Atan2(vectToEnemy.y, vectToEnemy.x) * Mathf.Rad2Deg);
            }
            //mtc.offset = new Vector3(_oldRightJoystickInputVector.x, _oldRightJoystickInputVector.y, -8);
            return(Mathf.Atan2(vertical, horizontal) * Mathf.Rad2Deg);
        }
        else
        {
            Vector3 diff = GetWorldPositionOnPlane(Input.mousePosition, 0) - self.position;
            diff.Normalize();

            float rot_z = Mathf.Atan2(diff.y, diff.x) * Mathf.Rad2Deg;
            return(rot_z);
        }
        mtc.offset             = new Vector3(_oldRightJoystickInputVector.x, _oldRightJoystickInputVector.y, -8);
        _rightStickInputActive = false;
        return(0f);
    }
Пример #14
0
 private void Start()
 {
     raisedLocation = transform.position + new Vector3(0, lavaRaisedY, 0);
     smoothTime     = 0.5f;
     camera         = GameObject.FindWithTag("Camera").GetComponent <MultipleTargetCamera>();
 }
Пример #15
0
 void Start()
 {
     _Overlord  = Overlord_Main._Overlord_main;
     _Ghost     = Overlord_Ghost._Overlord_Ghost;
     _Camera    = MultipleTargetCamera._MultipleTargetCamera;
     rbPlayer   = transform.GetComponent <Rigidbody> ();
     healthText = gameObject.transform.GetChild(2).gameObject.GetComponent <TextMesh> ();
     if (gameObject.tag == "Player_01")
     {
         if (_Ghost.player_01 == false)
         {
             this.gameObject.SetActive(false);
             if (hud != null)
             {
                 hud.SetActive(false);
             }
         }
         else
         {
             _Overlord.player01Alive = true;
         }
         if (hud == null)
         {
             hud = GameObject.Find("HUD_Player_01");
         }
     }
     if (gameObject.tag == "Player_02")
     {
         if (_Ghost.player_02 == false)
         {
             this.gameObject.SetActive(false);
             if (hud != null)
             {
                 hud.SetActive(false);
             }
         }
         else
         {
             _Overlord.player02Alive = true;
         }
         if (hud == null)
         {
             hud = GameObject.Find("HUD_Player_02");
         }
     }
     if (gameObject.tag == "Player_03")
     {
         if (_Ghost.player_03 == false)
         {
             this.gameObject.SetActive(false);
             if (hud != null)
             {
                 hud.SetActive(false);
             }
         }
         else
         {
             _Overlord.player03Alive = true;
         }
         if (hud == null)
         {
             hud = GameObject.Find("HUD_Player_03");
         }
     }
     if (gameObject.tag == "Player_04")
     {
         if (_Ghost.player_04 == false)
         {
             this.gameObject.SetActive(false);
             if (hud != null)
             {
                 hud.SetActive(false);
             }
         }
         else
         {
             _Overlord.player04Alive = true;
         }
         if (hud == null)
         {
             hud = GameObject.Find("HUD_Player_04");
         }
     }
 }
Пример #16
0
 private void Awake()
 {
     cam = GameObject.FindObjectOfType <MultipleTargetCamera>();
 }
Пример #17
0
 void Start()
 {
     radar        = GetComponent <CircleCollider2D> ();
     cam          = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <MultipleTargetCamera> ();
     radar.radius = 6f;
 }
Пример #18
0
 void Awake()
 {
     _MultipleTargetCamera = this;
 }