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

        p_c = followTarget.GetComponent <Player_controller>();
    }
示例#3
0
 private void Start()
 {
     _playerRB         = GetComponent <Rigidbody2D>();
     _playerAnimator   = GetComponent <Animator>();
     _playerController = GetComponent <Player_controller>();
     _audioSource      = GetComponent <AudioSource>();
 }
示例#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>();
     }
 }
示例#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>();
 }
示例#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;
     }
 }
示例#8
0
    public void jump_fun()
    {
        if (plc == null)
        {
            plc = Game_Manager.instance.player.GetComponent <Player_controller>();
        }

        plc.jump();
    }
示例#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;
     }
 }
示例#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);
    }
示例#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();
     }
 }
示例#14
0
文件: Weapon.cs 项目: LOOKCC/space
 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);
 }
示例#15
0
    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);
            }
        }
    }
示例#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);
        }
    }
示例#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);
        }
    }
示例#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);
        }
    }
示例#19
0
    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);
        }
    }
示例#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);
        }
    }
示例#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);
        }
    }
示例#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);
    }
示例#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);
    }
示例#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;
        }
    }
示例#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);
    }
示例#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);
            }
        }
    }
示例#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;
        }
    }
示例#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> ();

	}