Exemple #1
0
    void Start()
    {
        GameObject p = GameObject.FindGameObjectWithTag("Player");

        p_c = p.GetComponent <Player_Controller>();
        p_s = p.GetComponent <Player_Shoot>();
    }
Exemple #2
0
 void Awake()
 {
     Player = Instantiate(AssetManager.Instance.Player_Prefab);
     AssetManager.Instance.Player = Player;
     cam        = Instantiate(AssetManager.Instance.Camera);
     cam.Player = Player;
 }
Exemple #3
0
 // Use this for initialization
 void Start()
 {
     player         = FindObjectOfType <Player_Controller> ();
     spriteRenderer = GetComponent <SpriteRenderer> ();
     StartOfRound(0);
     isEnabled = true;
 }
    void OnTriggerExit(Collider other)
    {
        //if player has left, set entered flag to false
        if (other.tag == "Player")
        {
            Player_Controller _player = other.GetComponent <Player_Controller>();
            _entered = false;
            //hide text
            if (_player.infoText != null)
            {
                _player.infoText.text = "";
                _player.infoText.gameObject.SetActive(false);
            }

            //run function if execute on exit
            if (executeOnExit)
            {
                obj = other.gameObject;

                functionToRun.Invoke(other.gameObject);
            }
            else
            {
                obj = null;
            }
        }
    }
Exemple #5
0
 public void StartReloading()
 {
     GunAnimation.Play("Reload");
     GunAnimation.CrossFadeQueued("Idle", 0.1f);
     ReloadGun = StartCoroutine(ReloadCO());
     Player_Controller.PutGunDown();
 }
Exemple #6
0
    void Start()
    {
        //Początkowe wartości
        if (CanDefend)
        {
            ShouldDefend = false;
            Response     = false;
            reactionTime = reactionTimeCD;
        }
        if (CanGroundAttack)
        {
            GroundAttackDuration = GroundAttackDurationCd;
            GroundAttackBreak    = GroundAttackBreakCd;
            groundAttacking      = false;
        }

        AttackDuration = AttackDurationCD;
        AttackBreak    = AttackBreakCD;
        attacking      = false;

        //Dołączenie komponentów
        gm          = GameObject.FindGameObjectWithTag("GameMaster").GetComponent <Game_Master>();
        anim        = gameObject.GetComponent <Animator>();
        enemy       = gameObject.GetComponent <Enemy>();
        audioPlayer = gameObject.GetComponent <AudioPlayer>();
        target      = GameObject.FindGameObjectWithTag("Player");
        player      = target.GetComponent <Player_Controller>();
        rgb2d       = gameObject.GetComponent <Rigidbody2D>();
        NormalMove  = true;
    }
    void Update()
    {
        Player_Controller player = GetComponent <Player_Controller>();
        MagicShield       shield = GetComponentInChildren <MagicShield>();

        if (player.curHealth == 3)
        {
            Heart1.SetActive(true);
            Heart2.SetActive(true);
            Heart3.SetActive(true);
        }
        else if (player.curHealth == 2)
        {
            Heart1.SetActive(true);
            Heart2.SetActive(true);
            Heart3.SetActive(false);
        }
        else if (player.curHealth == 1)
        {
            Heart1.SetActive(true);
            Heart2.SetActive(false);
            Heart3.SetActive(false);
        }
        else if (player.curHealth == 0)
        {
            Heart1.SetActive(false);
            Heart2.SetActive(false);
            Heart3.SetActive(false);
        }

        shieldTimer.text = "Shield Timer " + System.Math.Round(shield.shieldUse, 0);
    }
Exemple #8
0
    // Use this for initialization

    void Start()
    {
        rb        = GetComponent <Rigidbody>();
        source    = GetComponents <AudioSource>()[1];
        BGMSource = GetComponents <AudioSource>()[0];
        pc        = GetComponent <Player_Controller>();
    }
 // Use this for initialization
 void Start()
 {
     hands.AddRange(GetComponentsInChildren <AI_Hit_Target>());
     p_control = GameObject.FindGameObjectWithTag("Player").GetComponent <Player_Controller>();
     anim      = GetComponent <AI_Animation_Controller>();
     rb        = GetComponent <Rigidbody>();
 }
Exemple #10
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
        GMState = GameManagerState.StartState;
        if (player != null && playCont != null)
        {
            playCont = player.GetComponent <Player_Controller>();
        }
        else
        {
            player = GameObject.FindGameObjectWithTag("Player");
            if (player != null)
            {
                playCont = player.GetComponent <Player_Controller>();
            }
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     rd            = GetComponent <Rigidbody2D>();
     Target        = GameObject.FindObjectOfType <Player_Controller>();
     movedirection = (Target.transform.position - transform.position).normalized * speed;
     rd.velocity   = new Vector2(movedirection.x, movedirection.y);
 }
    public void Initialize()
    {
        StartCoroutine("Order_Routine");
        pointsText.gameObject.SetActive(true);

        player = Gameplay_Manager.Instance.player;
    }
Exemple #13
0
    private void OnTriggerEnter(Collider other)
    {
        if (!PhotonNetwork.IsMasterClient)
        {
            return;
        }
        if (other.CompareTag("Player"))
        {
            Player_Controller player = Game_Manager.instance.GetPlayer(other.gameObject);

            if (type == PickupType.Health)
            {
                player.photonView.RPC("Heal", player.photonPlayer, value);
            }
            else if (type == PickupType.Ammo)
            {
                player.photonView.RPC("GiveAmmo", player.photonPlayer);
            }
            else if (type == PickupType.Rifle)
            {
                player.photonView.RPC("ChangeWeapon", player.photonPlayer, value, ammo, reserve, focalLength, fireRate, isAuto);
            }
            else if (type == PickupType.Sniper)
            {
                player.photonView.RPC("ChangeWeapon", player.photonPlayer, value, ammo, reserve, focalLength, fireRate, isAuto);
            }
            else if (type == PickupType.Bazooka)
            {
                player.photonView.RPC("ChangeWeapon", player.photonPlayer, value, ammo, reserve, focalLength, fireRate, isAuto);
            }

            //gameObject.SetActive(false);
            PhotonNetwork.Destroy(gameObject);
        }
    }
Exemple #14
0
    // Use this for initialization
    void Start()
    {
        rb     = this.GetComponent <Rigidbody2D> ();
        player = FindObjectOfType <Player_Controller> ();

        angle = (player.transform.position - this.transform.position).normalized;
    }
Exemple #15
0
    private void OnTriggerStay(Collider other)
    {
        if (other.tag == "PlayerBody")
        {
            if (damageTimer <= 0)
            {
                state = State.Combat;
                if (Vector3.Distance(player.transform.position, transform.position) < 2)
                {
                    Player_Controller player = other.GetComponentInParent <Player_Controller>();
                    player.Damage();
                }
                damageTimer = 1;
            }
            else
            {
                damageTimer -= Time.deltaTime;
            }
        }

        if (other.tag == "ShockWave")
        {
            state = State.Combat;
        }
    }
Exemple #16
0
    public void SaveLavelId(int id, GameData gmdata) //służy do zapisania id sceny do której się właśnie weszło
    {
        gameMaster.saving = true;                    //gra jest zapisywana

        player = GameObject.FindGameObjectWithTag("Player").GetComponent <Player_Controller>();
        idb    = gameObject.GetComponent <itemDataBase>();

        Debug.Log("Saveing level id");

        //Posłuży do przesyłania danych do pliku.
        //Unity ma własną konfigurację w tym wyspecyfikowane miejsce, w którym składuje takie pliki.
        //Pod Windows jest to z reguły miejsce w katalogu użytkownika.
        FileStream plik = File.Create(Application.persistentDataPath + "/Record.data");

        // Obiekt zawierający informacjie o stanie naszego gracza.

        gmdata.SceneId = Application.loadedLevel; //Pobieram id poziomu

        //Posłuży do zapisywania danych do pliku.
        BinaryFormatter bf = new BinaryFormatter();

        //Serializujemy/zapisujemy dane do pliku
        bf.Serialize(plik, gmdata);
        plik.Close();//Zamykamy plik (kończymy operacje na pliku).

        Debug.Log("Saveing - save level id = " + SceneManager.GetActiveScene().buildIndex);

        gameMaster.saving = false;
    }
 // Start is called before the first frame update
 void Start()
 {
     player = GameObject.FindObjectOfType <Player_Controller>();
     enemy  = GameObject.FindObjectOfType <Enemy>();
     ads    = GameObject.FindObjectOfType <LogicalAds>();
     round.SetActive(true);
 }
Exemple #18
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            if (collision.gameObject.name == "Player1" || collision.gameObject.name == "Player1(Clone)")
            {
                if (p1.items.Contains("Key"))
                {
                    had_key1 = true;
                }
                Destroy(collision.gameObject);
                p1 = Instantiate(Player1);
                if (had_key1)
                {
                    p1.items.Add("Key");
                }
            }

            else
            {
                if (p2.items.Contains("Key"))
                {
                    had_key2 = true;
                }
                Destroy(collision.gameObject);
                p2 = Instantiate(Player2);
                if (had_key2)
                {
                    p2.items.Add("Key");
                }
            }
        }
        gameObject.transform.localScale = new Vector2(-gameObject.transform.localScale.x, gameObject.transform.localScale.y);
    }
Exemple #19
0
    bool CountDownPlayFlg    = false;                   // カウントダウンのSEの再生フラグ

    // Start is called before the first frame update
    void Start()
    {
        GenelateTimer = 0;  // タイマーの初期化
        //GameTimer = 0; // ゲームタイマーの初期化
        CountDownTimer = 4; // カウントダウンタイマーの初期化
        tmpGameTimer   = GameTimer;

        //コンポーネントを取得
        audioSource = GetComponent <AudioSource>();

        //人数に応じてプレイヤーを生成
        for (int i = 0; i < Player_Count; i++)
        {
            GameObject Player = Instantiate(Player_Obj, new Vector3(SpawnPoint[i].transform.position.x, 2f, SpawnPoint[i].transform.position.z), Quaternion.identity) as GameObject;
            Player.name = "Player_" + i;
            Player_Controller pc = Player.GetComponent <Player_Controller>();
            pc.SetPlayerNum(i);
            PlayerBox = GameObject.Find("PlayerBox");
            Player.transform.parent = PlayerBox.transform; // 子オブジェクトとしてセット
            Player_Score[0]         = 0;
        }

        //人数に応じてスコアUIを表示
        for (int i = 0; i < Player_Count; i++)
        {
            ScoreUI[i].SetActive(true); // 表示
        }

        //audioSource.PlayOneShot(GameMusic); //BGMを再生
        //audioSource.PlayOneShot(CountDownSE[0]);
    }
Exemple #20
0
 void Start()
 {
     player = GameObject.FindGameObjectWithTag("Player");
     tr     = player.GetComponent <Transform>();
     p_c    = player.GetComponent <Player_Controller>();
     sp     = GetComponent <SpriteRenderer>();
 }
Exemple #21
0
    void Start()
    {
        //ustawienia dźwięku
        audioSource      = gameObject.GetComponent <AudioSource>();
        audioSource.loop = true;
        audioSource.clip = startClip;
        audioSource.Play();

        can = true;//Możliwość zamknięcia

        //Komponenty
        gm           = GameObject.FindGameObjectWithTag("GameMaster").GetComponent <Game_Master>();
        keyMenager   = GameObject.Find("KeyMenager").GetComponent <KeyMenager>();
        anim         = gameObject.GetComponent <Animator>();
        player       = GameObject.FindGameObjectWithTag("Player").GetComponent <Player_Controller>();
        playerAttack = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerAttack>();

        hp = Random.Range(2, 5); //ilość pozyskanego hp

        //Odwrócenie obiektu
        if (player.facingRight)
        {
            transform.localScale = new Vector3(1, 1, 1);
        }
        else
        {
            transform.localScale = new Vector3(-1, 1, 1);
        }

        anim.SetBool("End", false);
    }
Exemple #22
0
    // Update is called once per frame
    void Update()
    {
        if (folkparken)
        {
            if (player == null)
            {
                player       = GameObject.FindWithTag("Player");
                playerScript = player.GetComponent <Player_Controller>();
                Debug.Log("Player found!");
            }
            if (manager == null)
            {
                manager       = GameObject.Find("Game Manager");
                managerScript = manager.GetComponent <Game_Manager>();
                Debug.Log("Manager found!");
            }


            if (playerScript.health <= 0)
            {
                healthText.text = "Oj oj";
            }
            else
            {
                healthText.text = "x " + playerScript.health.ToString();
            }

            scoreText.text = "SCORE: " + PlayerStats.Score.ToString();

            timeText.text = "TIME: " + managerScript.gameTime.ToString("0");
        }
    }
Exemple #23
0
 // Use this for initialization
 void Start()
 {
     player           = GameObject.Find("Player");
     controller       = player.GetComponent <Player_Controller>();
     obstacleCollider = GetComponent <Collider2D>();
     playerCollider   = player.GetComponent <Collider2D>();
 }
Exemple #24
0
    IEnumerator RespawnPlayer()
    {
        if (checkPoint.position != Vector3.zero)
        {
            Player_Controller controller = GetComponent <Player_Controller>();

            controller.enabled = false;

            StopCoroutine(DrainEnergyPeriodically());

            yield return(new WaitForSeconds(respawnTimer));

            _isAlive           = true;
            currentEnergy      = maxEnergy;
            transform.position = checkPoint.position;

            if (HudUpdate != null)
            {
                HudUpdate(PowerTypes.POWER_ENERGY, currentEnergy);
            }

            StartCoroutine(DrainEnergyPeriodically());

            controller.enabled = true;
        }
    }
Exemple #25
0
 private void OnTriggerExit2D(Collider2D info)
 {
     if (_player == info.GetComponent <Player_Controller>())
     {
         _player = null;
     }
 }
Exemple #26
0
 // Start is called before the first frame update
 public virtual void Start()
 {
     rb             = GetComponent <Rigidbody2D>();               //Grab the component of the local RigidBody
     controller     = GetComponent <Player_Controller>();
     originPosition = gameObject.transform.position;              //The start position of this gameObject
     playerPosition = FindObjectOfType <Player_Pawn>().transform; //The player's position
 }
Exemple #27
0
 private void Start()
 {
     player = FindObjectOfType <Player_Controller>();
     music  = this.GetComponent <AudioSource>();
     music.Play();
     StartPanel.SetActive(true);
 }
Exemple #28
0
    void RandomRecoil(Camera_Controller cameraController, Player_Controller playerController)
    {
        int _recoilIndex = Random.Range(0, weaponStats.recoilPattern.Count - 1);

        cameraController.xRotation -= weaponStats.recoilPattern[_recoilIndex].x * weaponStats.baseRecoil * recoilADS;
        playerController.yRotation += weaponStats.recoilPattern[_recoilIndex].y * weaponStats.baseRecoil * recoilADS;
    }
Exemple #29
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            Player_Controller player = other.GetComponent <Player_Controller>();
            if (player != null)
            {
                player.Damage();
            }
            AudioSource.PlayClipAtPoint(_audioClipPlayerHit, transform.position);
            GameObject Effect = Instantiate(_particleEffect, transform.position, Quaternion.identity);
            Destroy(Effect, 0.5f);
            Destroy(this.gameObject);
        }

        if (other.tag == "Bullet")
        {
            other.gameObject.SetActive(false);
            if (_player != null)
            {
                _player.AddScore(10);
            }
            AudioSource.PlayClipAtPoint(_audioClipExplosion, transform.position);
            GameObject Effect = Instantiate(_particleEffect, transform.position, Quaternion.identity);
            Destroy(Effect, 0.5f);
            Destroy(GetComponent <Collider2D>());
            Destroy(this.gameObject);
        }
    }
Exemple #30
0
 void Start()
 {
     player   = FindObjectOfType <Player_Controller> ();
     icon     = this.GetComponent <Image> ();
     duration = theItem.duration;
     timeLeft = duration;
 }
Exemple #31
0
 private void Awake()
 {
     if (networkView.isMine)
     {
         CharacterController = GetComponent("CharacterController") as CharacterController;
         Instance = this;
     }
 }
 void Start () {
     agent = GetComponent<NavMeshAgent>();
     player_controller = GameObject.FindGameObjectWithTag("Player").GetComponent<Player_Controller>();
     startPosition = transform.position;
     agent.speed = Random.Range(2.0f, 3.0f);
     counter = 0;
     maxHealth = 30;
     health = 30;
 }
Exemple #33
0
 void OnCollisionEnter(Collision col)
 {
     if (!ZderzylSie)
     {
         kontroller = col.gameObject.GetComponent<Player_Controller>();
         if (kontroller != null)
         {
             kontroller.GetDamage(1);
             kontroller.shorecrash = 0;
             ZderzylSie = true;
             //Debug.Log("zderzenie z brzegiem");
         }
     }
 }
Exemple #34
0
    void OnCollisionEnter(Collision col)
    {
        if (!ZderzylSie)
        {
            kontroller = col.gameObject.GetComponent<Player_Controller>();
            if (kontroller != null)
            {
                kontroller.GetDamage(1);

                this.collider.enabled = false;
            }

            //Debug.Log("zderzenie");

        }

        ZderzylSie = true;
    }
	// Use this for initialization
	void Start () {
		playerDeath = (Player_Controller)FindObjectOfType (typeof(Player_Controller));
		realStatus ();
	}
 public override void Startup(Player_Controller _thePlayer)
 {
     base.Startup (_thePlayer);
     _state = "ground";
     _lastState = "ground";
 }
Exemple #37
0
 // Use this for initialization
 void Start()
 {
     controller = GetComponent<Player_Controller> ();
     playerCamera = transform.FindChild ("Camera").GetComponent<Camera> ();
 }
	void Awake(){
		sInstance = this;
		m_Exploder = GetComponent<ExploderObject>();
		mTouch_Start = new Vector2[10];
		mTouch_End = new Vector2[10];
		TouchDetectRange = new Vector2 (50f,50f);
       
	}
 void Awake()
 {
     instance = this;
 }
 public override void Startup(Player_Controller _thePlayer)
 {
     base.Startup (_thePlayer);
     _usesNodes = true;
     _state = "attached";
     _lastState = "attached";
 }
	void Awake ()
    {
        characterController = GetComponent("CharacterController") as CharacterController;
        Instance = this;
        //Player_Camera.createMainCamera();
	}
Exemple #42
0
 // Use this for initialization
 void Start()
 {
     player = FindObjectOfType<Player_Controller>(); //shortform of reference
 }
Exemple #43
0
    protected void Update()
    {
        pc = GetComponent<Player_Controller>();

        if(recoiltime <= 0)
        {
            recoiltime = 0;
        }
        else
        {
            recoiltime = recoiltime - Time.deltaTime;
        }

        if(pc.GetKeyDown(4))
        {
            if(pulos>0)
            {
                  GetRigido().AddForce(Vector2.up*250,ForceMode2D.Impulse);
                pulos --;

            }

        }
        GameObject parent_bone = this.transform.FindChild ("bones_parent").gameObject;
        Vector3 rot = parent_bone.transform.rotation.eulerAngles;
        if(pc.GetKey(2))
        {
            if(pc.GetKey(1) == false && pc.GetKey(3) == false)
            {
                rot.z = 90;
            }
            else
            {
                rot.z = 45;
            }
        }

        if(pc.GetKey(0))
        {
            if(pc.GetKey(1) == false && pc.GetKey(3) == false)
            {
                rot.z = -90;
            }
            else
            {
                rot.z = -45;
            }
        }
        if(pc.GetKey(2) == false && pc.GetKey(0) == false)
        {
            rot.z = 0;
        }

        parent_bone.transform.rotation = Quaternion.Euler(rot);
          GetGun(1).transform.rotation = Quaternion.Euler(rot);
          GetGun(2).transform.rotation = Quaternion.Euler(rot);

        if(pc.GetKey(1) == false && pc.GetKey(3) == false)
        {

        }
        else
        {
            Quaternion rotation = this.transform.rotation;
            Vector2 oldspeed =   GetRigido().velocity;
            oldspeed.x = 0;
            if(pc.GetKey (1))
            {
                rotation.y = 0;
                oldspeed.x = oldspeed.x - 10;

            }
            if(pc.GetKey (3))
            {
                rotation.y = 180;
                oldspeed.x = oldspeed.x + 10;
            }
            this.transform.rotation = rotation;
              GetRigido().velocity = oldspeed;
        }

        if(pc.GetKey(5))
        {
            if(recoiltime == 0)
            {
                Vector3 position = new Vector3();
                if(  Getmain() == true)
                {
                    if(  Getmult() == true)
                    {
                        position =   GetGun (0).transform.position;
                        GameObject Boolet;
                        for(int i = 0; i < 5;i++)
                        {
                            Boolet = Instantiate(  GetBullet(),position,randomRotation(  GetGun (0).transform.rotation,-10,10)) as GameObject;
                            Boolet.GetComponent<Bullet_code>().SetOwner(this.name);
                        }

                    }
                    else
                    {
                        position =   GetGun (0).transform.position;
                        GameObject Boolet = Instantiate(  GetBullet(),position,  GetGun (0).transform.rotation) as GameObject;
                        Boolet.GetComponent<Bullet_code>().SetOwner(this.name);
                    }

                }
                else
                {
                    if(  Getalt() == false)
                    {
                        position =   GetGun (1).transform.position;
                        GameObject Boolet = Instantiate(  GetBullet(),position,  GetGun (1).transform.rotation) as GameObject;
                        Boolet.GetComponent<Bullet_code>().SetOwner(this.name);
                        position =   GetGun (2).transform.position;
                        Boolet = Instantiate(  GetBullet(),position,  GetGun (2).transform.rotation) as GameObject;
                        Boolet.GetComponent<Bullet_code>().SetOwner(this.name);
                    }
                    else
                    {
                        position =   GetGun (wichgun).transform.position;
                        GameObject Boolet = Instantiate(  GetBullet(),position,  GetGun (wichgun).transform.rotation) as GameObject;
                        Boolet.GetComponent<Bullet_code>().SetOwner(this.name);
                        wichgun ++;
                        if(wichgun >= 3){wichgun =1;}
                    }
                }

                recoiltime =   getrate();

            }

        }
    }
 public override void Startup(Player_Controller _thePlayer)
 {
     base.Startup (_thePlayer);
     _state = "stasis";
 }
Exemple #45
0
 //this bit is just to get all the variables that I need taken from the player controller script
 public virtual void Startup(Player_Controller _thePlayer)
 {
     //sets all the variables
     _player = _thePlayer;
     _rigid = _thePlayer.GetComponent<Rigidbody> ();
     _maxSpeed = _player.maxSpeed;
     _acceleration = _player.acceleration;
     _jumpPower = _player.jumpPower;
     _nodeJumpPower = _player.nodeJumpPower;
     _turnSpeed = _player.turnSpeed;
     _cameraTrans = _player.cameraTrans;
     _camera = _cameraTrans.GetComponent<Camera_Controller> ();
     _groundD = _player._groundD;
     _anim = _player.anim;
     _speedText = _player.speedText;
     _camMover = _player.camMover;
     _forwardD = _player._forwardD;
     //_nodeD = _player._nodeD;
 }
 public virtual void Startup(Camera_Controller _controller)
 {
     _camTrans = _controller.transform;
     _orbitSpeed = _controller.orbitSpeed;
     _player = _controller.player.GetComponent<Player_Controller> ();
     _rigid = _player.gameObject.GetComponent<Rigidbody> ();
 }