示例#1
0
    void Spawn(AttackerScript myAttacker)
    {
        AttackerScript newAttacker = Instantiate(myAttacker, transform.position, transform.rotation);

        // newAttacker.transform.parent = transform;
        newAttacker.transform.SetParent(transform);
    }
示例#2
0
    public void OnEnter()
    {
        if (playerController.selectedGameObject != null)
        {
            originalCamRot = Camera.main.transform.rotation;
            originalCamPos = Camera.main.transform.position;

            attacker = playerController.selectedGameObject.GetComponent <AttackerScript>();

            lookCamera = Camera.main;

            lookCamera.transform.position = attacker.CurrentWeapon.WeaponMount.position;
            lookCamera.transform.rotation = attacker.CurrentWeapon.WeaponMount.rotation;

            targetFoV = originalFoV = lookCamera.fieldOfView;
            //MouseLook.Init(transform, lookCamera.transform);
            CrossHairImage.gameObject.SetActive(true);
            CrossHairImage_Actual.gameObject.SetActive(true);

            Debug.Log("Locking mouse cursor");
            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible   = false;

            //  gameEventSystem.RaiseEvent(GameEventType.AttackModeEntered, attacker.gameObject, null);
        }
    }
示例#3
0
    void OnTriggerStay2D(Collider2D otherCollider)
    {
        AttackerScript attacker = otherCollider.GetComponent <AttackerScript>();

        if (attacker)
        {
            // attacker.Attack(gameObject);
        }
    }
示例#4
0
    void OnTriggerStay2D(Collider2D collider)
    {
        AttackerScript attacker = collider.gameObject.GetComponent <AttackerScript>();

        if (attacker)
        {
            animate.SetTrigger("UnderAttackTrigger");
        }
    }
    private void OnTriggerEnter2D(Collider2D collider)
    {
        GameObject     obj      = collider.gameObject;
        AttackerScript attacker = obj.GetComponent <AttackerScript>();

        if (attacker)
        {
            int dmg = attacker.GetDamageOnTouchdown();
            playerHealth.TakeDamage(dmg);
            Destroy(obj);
        }
    }
    private void OnTriggerEnter2D(Collider2D collider)
    {
        GameObject     go             = collider.gameObject;
        AttackerScript attacker       = go.GetComponent <AttackerScript>();
        Health         attackerHealth = go.GetComponent <Health>();

        if (attacker && attackerHealth)
        {
            attackerHealth.TakeDamage(damage);
            Destroy(gameObject);
        }
    }
    bool IsTimeToSpawn(GameObject attacker)
    {
        // E.g. To spawn Fox every ten seconds on average,
        //at 10 frames per second, that means
        // ideally once every 100 frames,
        // or a probability of 1% on any frame (assuming 10FPS)
        // calculation: prob: 1 / (spawnPeriod * FPS)
        AttackerScript script      = attacker.GetComponent <AttackerScript>();
        float          fps         = 1 / Time.smoothDeltaTime;
        float          probability = 1 / (script.seenEverySeconds * fps);

        return(Random.value < probability);
    }
示例#8
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        AttackerScript attack = collider.gameObject.GetComponent <AttackerScript>();
        HealthScript   health = collider.gameObject.GetComponent <HealthScript>();

        if (attack && health)
        {
            health.UnderAttack(damage);
            Destroy(gameObject);
        }

        /*	bool check = collider.GetComponent<AttackerScript>();
         * if(check == true) {
         * HealthScript health = collider.GetComponent<HealthScript>();
         * health.UnderAttack(damage);
         * Destroy (gameObject);
         * }else return;	*/
    }
示例#9
0
    bool TimeToSpawn(GameObject attackerGameObject)
    {
        AttackerScript myAttacker      = attackerGameObject.GetComponent <AttackerScript>();
        float          secondsPerSpawn = myAttacker.spawnRate;
        float          spawnsPerSecond = 1 / secondsPerSpawn;

        if (Time.deltaTime > secondsPerSpawn)
        {
            Debug.LogWarning("Spawn rate capped by frame rate");
        }
        // Setting difficulty by progressive increase in spawn rate

        /* GameTimerScript gameTimer = GameObject.FindObjectOfType<GameTimerScript>();
         *      difficultyFactor -= (5/gameTimer.levelSeconds)* Time.deltaTime; */

        float threshold = (spawnsPerSecond * Time.deltaTime) / difficultyFactor;

        return(Random.value < threshold);
    }
示例#10
0
 void Start()
 {
     animator       = GetComponent <Animator>();
     attackerScript = GetComponent <AttackerScript>();
 }
 void Start()
 {
     attacker    = GetComponent <AttackerScript>();
     animate     = GetComponent <Animator>();
     audioSource = GetComponent <AudioSource>();
 }