Inheritance: MonoBehaviour
Example #1
0
 private void OnTriggerExit2D(Collider2D info)
 {
     if (_player == info.GetComponent <Player_controller>())
     {
         _player = null;
     }
 }
Example #2
0
    void Start()
    {
        CamPosition        = transform.position;
        transform.rotation = Quaternion.Euler(CamRotOffset);

        p_c = followTarget.GetComponent <Player_controller>();
    }
Example #3
0
 private void Start()
 {
     _playerRB         = GetComponent <Rigidbody2D>();
     _playerAnimator   = GetComponent <Animator>();
     _playerController = GetComponent <Player_controller>();
     _audioSource      = GetComponent <AudioSource>();
 }
Example #4
0
 // Use this for initialization
 void Start()
 {
     cvar_watcher = FindObjectOfType <Server_watcher>();
     Darkness     = GameObject.Find("Darkness");
     fade_view    = GameObject.Find("Fade_view");
     if (!cvar_watcher.losVision)
     {
         Destroy(Darkness);
         Destroy(fade_view);
         Destroy(this);
         return;
     }
     fade_view_left  = fade_view.transform.Find("Fade_view_leaf_left");
     fade_view_right = fade_view.transform.Find("Fade_view_leaf_right");
     controller      = GetComponent <Player_controller>();
     if (!controller.isLocalPlayer)
     {
         Destroy(this);
         return;
     }
     body                           = GetComponent <Body_generic>();
     viewMesh                       = new Mesh();
     viewMesh.name                  = "View Mesh";
     viewMeshFilter.mesh            = viewMesh;
     sprite_orient                  = GetComponent <Player_controller>().sprite_orient;
     fade_view.transform.localScale = new Vector2(body.viewRadius, body.viewRadius);
     fade_view_left.localRotation   = Quaternion.Euler(0, 0, body.viewAngle / 2);
     fade_view_right.localRotation  = Quaternion.Euler(0, 0, -body.viewAngle / 2);
     //StartCoroutine("FindTargetsWithDelay", 0.2f);
 }
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         Player = other.gameObject;
         p_c    = Player.GetComponent <Player_controller>();
     }
 }
Example #6
0
 // Use this for initialization
 void Start()
 {
     State    = Game_State.Game_Enemy;
     preState = Game_State.Game_Player;
     player   = GameObject.FindGameObjectWithTag("PlayerController").GetComponent <Player_controller>();
     AI       = GameObject.FindGameObjectWithTag("AIController").GetComponent <AIConrtoller>();
     supply   = GameObject.FindGameObjectWithTag("GameSupply").GetComponent <Supply>();
 }
Example #7
0
 // Use this for initialization
 void Start()
 {
     player  = GameObject.FindGameObjectWithTag("PlayerController").GetComponent <Player_controller>();
     radious = control_in.transform.position.x;
     for (int i = 0; i < balls.Length; i++)
     {
         balls[i] = Instantiate(ball) as GameObject;
     }
 }
Example #8
0
    public void jump_fun()
    {
        if (plc == null)
        {
            plc = Game_Manager.instance.player.GetComponent <Player_controller>();
        }

        plc.jump();
    }
Example #9
0
    public void setBtnEvent(int move)
    {
        if (plc == null)
        {
            plc = Game_Manager.instance.player.GetComponent <Player_controller>();
        }

        plc.set_mobile_move(move);
    }
 private void OnTriggerExit(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         p_c.maxJumpCount = 2;
         Player           = null;
         p_c = null;
         isBeingInteracted = false;
     }
 }
Example #11
0
    // Update is called once per frame
    void FixedUpdate()
    {
        Player_controller s_controller = player.GetComponent <Player_controller>();
        float             scaleRate    = s_controller.scaleRate;

        transform.localScale += new Vector3(scaleRate, scaleRate, scaleRate);

        this.transform.position = player.transform.position + offset;
        //this.transform.localPosition = new Vector3(0, 0, 0);
    }
Example #12
0
    private void OnTriggerEnter(Collider collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            GlobalVariables.HorizontalMovement = false;

            Player = collision.gameObject;
            P_c    = Player.GetComponent <Player_controller>();
        }
    }
 void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "Player01")
     {
         // ... stop the nav mesh agent
         nav.Stop();
         // ... set the PlayerDead parameter inside Animator Controller
         animator.SetTrigger("PlayerDead");
         // ... call players Death function
         Player_controller playerController = player.gameObject.GetComponent <Player_controller>();
         playerController.Death();
     }
 }
Example #14
0
 void Start()
 {
     control       = GameObject.FindGameObjectWithTag("GameController").GetComponent <Control>();
     player        = GameObject.FindGameObjectWithTag("PlayerController").GetComponent <Player_controller>();
     screen_width  = Screen.width;
     screen_height = Screen.height;
     map_width     = mini_map.transform.position.x * 2;
     map_height    = (screen_height - mini_map.transform.position.y) * 2;
     SmallBomb.SetActive(false);
     BigBomb.SetActive(false);
     Cannon.SetActive(false);
     Bird.SetActive(false);
     MoveBomb.SetActive(false);
 }
    protected void Strike()
    {
        Collider2D player = Physics2D.OverlapBox(_strikePoint.position, new Vector2(_strikeRange, _strikeRange), 0, _enemies);

        if (player != null)
        {
            Player_controller playerControler = player.GetComponent <Player_controller>();
            int damage = _damage;
            if (playerControler != null)
            {
                playerControler.TakeDamage(damage);
            }
        }
    }
Example #16
0
    private void OnTriggerEnter2D(Collider2D info)
    {
        if ((DateTime.Now - _lastEncounter).TotalSeconds < _timeDelay / 2)
        {
            return;
        }

        _lastEncounter = DateTime.Now;
        _player        = info.GetComponent <Player_controller>();
        if (_player != null)
        {
            _player.TakeTamage(_damage);
        }
    }
Example #17
0
    private void OnTriggerEnter2D(Collider2D info)
    {
        if ((DateTime.Now - _lastEncounter).TotalSeconds < 0.1f) //добавил
        {
            return;                                              //добавил
        }
        _lastEncounter = DateTime.Now;                           //добавил

        _player = info.GetComponent <Player_controller>();
        if (_player != null)
        {
            _player.TakeDamage(_damage);
        }
    }
Example #18
0
    private void OnTriggerEnter2D(Collider2D info)
    {
        if ((DateTime.Now - lastEncounter).TotalSeconds < 0.1f)
        {
            return;
        }

        lastEncounter = DateTime.Now;
        player        = info.GetComponent <Player_controller>();
        if (player != null)
        {
            player.TakeDamageFromTraps(-damage);
        }
    }
    protected virtual void TryToDamage(Collider2D enemy)
    {
        if ((Time.time - lastDamageTime) < collisionTimeDelay)
        {
            return;
        }

        Player_controller player = enemy.GetComponent <Player_controller>();

        if (player != null)
        {
            player.TakeDamage(collisionDamage, collisionDamageType, transform);
        }
    }
Example #20
0
    private void OnTriggerEnter2D(Collider2D info)
    {
        if ((DateTime.Now - lastEncounter).TotalSeconds < 0.02f)
        {
            return;
        }

        lastEncounter = DateTime.Now;
        player        = info.GetComponent <Player_controller>();

        if (player != null)
        {
            player.TakeDamage(damage, DamageType.PowerStrike, gameObject.transform);
        }
    }
Example #21
0
    private void OnTriggerEnter2D(Collider2D info)
    {
        if ((DateTime.Now - _LastEncounter).TotalSeconds < 0.1f)
        {
            return;
        }

        _LastEncounter = DateTime.Now;

        _player = info.GetComponent <Player_controller>();
        if (_player != null)
        {
            _player.ChangeHp(-_damage);
        }
    }
Example #22
0
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);

        m_RGB  = GetComponent <Rigidbody2D>();
        m_anim = GetComponentInChildren <Animator>();
    }
    private void OnTriggerEnter2D(Collider2D info)
    {
        if (Time.time - _lastEncounter < 0.1f)
        {
            return;
        }

        _lastEncounter = Time.time;
        Player_controller player = info.GetComponent <Player_controller>();

        if (player != null)
        {
            player.TakeDamage(_damage);
        }
        Destroy(gameObject);
    }
Example #24
0
    private void OnTriggerEnter2D(Collider2D info)
    {
        if (_damaged)
        {
            return;
        }

        Player_controller target = info.GetComponent <Player_controller>();

        if (target != null)
        {
            _damaged = true;
            target.TakeTamage(_damage, DamageType.Projectile, transform);
        }

        Destroy(gameObject);
    }
Example #25
0
    // Update is called once per frame
    void LateUpdate()
    {
        if (player.GetComponent <Player_controller>().gameLost || player.GetComponent <Player_controller>().gameWon)
        {
            //stop the particles
            GetComponent <ParticleSystem>().Stop();
        }
        else
        {
            Player_controller s_controller = player.GetComponent <Player_controller>();
            float             scaleRate    = s_controller.scaleRate;

            transform.localScale += new Vector3(scaleRate, scaleRate, scaleRate);

            distance = minDistance + scaleRate;

            transform.position = (offset).normalized * distance + follow.transform.position;
        }
    }
Example #26
0
    string get_weapon_name(GameObject subject)
    {
        if (subject.GetComponent <Body_generic>().isPlayer)
        {
            Player_controller player = subject.GetComponent <Player_controller>();
            if (player.equiped_item == null)
            {
                return("nothing");
            }
            return(subject.GetComponent <Player_controller>().equiped_item.name);
        }
        AI_generic ai = subject.GetComponent <AI_generic>();

        if (ai.equiped_item == null)
        {
            return("nothing");
        }
        return(subject.GetComponent <AI_generic>().equiped_item.name);
    }
Example #27
0
    protected virtual void TryToDamage(Collision2D enemy)
    {
        if (enemy == null)
        {
            return;
        }

        if ((Time.time - _lastDamageTime) < _collisionTimeDelay)
        {
            return;
        }

        Player_controller player = enemy.gameObject.GetComponent <Player_controller>();

        if (player != null)
        {
            player.TakeTamage(_collisionDamage, _collisionDamageType, transform);
            _lastDamageTime = Time.time;
        }
    }
    void Start()
    {
        instance   = this;
        keyB       = PlayerPrefs.GetInt("chaveB");
        keyG       = PlayerPrefs.GetInt("chaveG");
        totalScore = PlayerPrefs.GetInt("pontuacao");
        i          = PlayerPrefs.GetInt("char");
        inicio     = PlayerPrefs.GetString("iniciar");

        if (inicio == "inicio")
        {
            if (i == 0)
            {
                Instantiate(players[0], startGame.transform.position, Quaternion.identity);
            }
            else if (i == 1)
            {
                Instantiate(players[1], startGame.transform.position, Quaternion.identity);
            }
        }
    }
Example #29
0
    protected virtual void TryToDamage(Collider2D enemy)
    {
        if (enemy == null)
        {
            return;
        }

        if ((Time.time - _lastDamageTime) < _collisionTimeDelay)
        {
            return;
        }

        Player_controller player = enemy.GetComponent <Player_controller>();

        if (player != null && !player.IsDead)
        {
            GetComponent <Animator>().Play("Attack");
            player.TakeTamage(_collisionDamage, _collisionDamageType, transform);
            _lastDamageTime = Time.time;
        }
    }
Example #30
0
    void Start()
    {
        i      = PlayerPrefs.GetInt("char");
        inicio = PlayerPrefs.GetString("iniciar");

        if (inicio == "inicio")
        {
            if (i == 0)
            {
                Instantiate(players[0], startGame.transform.position, Quaternion.identity);
            }
            else if (i == 1)
            {
                Instantiate(players[1], startGame.transform.position, Quaternion.identity);
            }
        }
        instance = this;
        keyB     = PlayerPrefs.GetInt("chaveB");
        keyG     = PlayerPrefs.GetInt("chaveG");
        player   = GameObject.FindGameObjectWithTag("Player");
    }
	// Use this for initialization
	void Start () {
		playRef = GameObject.Find ("Mario").GetComponent<Player_controller> ();
	}
	// Use this for initialization
	void Start () {
		playerRefer = GameObject.Find ("Mario").GetComponent<Player_controller> ();
		testItem = GameObject.FindGameObjectWithTag("block").GetComponentInChildren<ChildScript>();
		stop = GameObject.FindGameObjectWithTag ("block").GetComponentInChildren<contactCheck> ();

	}