예제 #1
0
    private Vector3 CalculateRandomError(Vector3 dir)
    {
        AI_Controller owner = UT_FindComponent.FindComponent <AI_Controller>(gameObject);

        if (owner == null)
        {
            return(dir);
        }

        SO_AI_Base bs = owner.GetBase();

        if (!bs.mFireInaccurately)
        {
            return(dir);
        }

        // now find a random spread up to the max spread.
        float spread = Random.Range(0, bs.mInacRange);

        if (Random.value > 0.5f)
        {
            spread *= -1;
        }

        // now apply that spread to the bullets direction.
        Vector3 newDir = Quaternion.AngleAxis(spread, Vector3.up) * dir;

        return(newDir);
    }
예제 #2
0
 private void Awake()
 {
     mRigid         = GetComponent <Rigidbody>();
     mEntity        = GetComponent <AI_Controller>();
     mAnim          = UT_FindComponent.FindComponent <AN_Enemies>(gameObject);
     mModelFollower = UT_FindComponent.FindComponent <ObjectFollower>(gameObject);
 }
예제 #3
0
    private void OnTriggerEnter(Collider other)
    {
        // Also want it destroying the lanky shield if it hits him
        if (hasBeenThrown)
        {
            EnemyForceField forceField = UT_FindComponent.FindComponent <EnemyForceField>(other.gameObject);
            if (forceField != null)
            {
                forceField.TakeDamage(10000f);
                DestroyObject();
                return;
            }
        }

        if ((other.GetComponent <DestroyObjectOnCollision>() != null && other.GetComponent <ThrowableObject>() == null) && hasBeenThrown)
        {
            DestroyObject();
            return;
        }

        AI_Controller npc = UT_FindComponent.FindComponent <AI_Controller>(other.gameObject);

        if (npc != null && hasBeenThrown)
        {
            npc.TakeDamage(properties.damage);
            addScore.Raise(pointsForEnemyKill);
            DestroyObject();
        }
    }
예제 #4
0
 private void OnTriggerEnter(Collider other)
 {
     if (UT_FindComponent.FindComponent <PlayerController>(other.gameObject))
     {
         mWallToDeactivate.gameObject.SetActive(false);
     }
 }
예제 #5
0
 private void Awake()
 {
     mRigid         = GetComponent <Rigidbody>();
     mEntity        = GetComponent <AI_Controller>();
     mAnim          = UT_FindComponent.FindComponent <AN_Enemies>(gameObject);
     mStunParticles = GetComponentInChildren <StunnedParticles>();
 }
예제 #6
0
    private void OnTriggerEnter(Collider other)
    {
        Destroy(gameObject);

        IDamageable damageableObject = other.GetComponent <IDamageable>();

        if (damageableObject != null)
        {
            if (other.GetComponent <AreaForceField>() != null)
            {
                damageableObject.TakeDamage(damageToAreaForceField);
                addScore.Raise(pointsForStunning);
                return;
            }
            if (other.GetComponent <EnemyForceField>() != null)
            {
                damageableObject.TakeDamage(damageToEnemyForceField);
                addScore.Raise(pointsForDestroyingShield);
                return;
            }
        }

        AI_TakesGrenade npc = UT_FindComponent.FindComponent <AI_TakesGrenade>(other.gameObject);

        if (npc != null)
        {
            npc.GetHitByGrenade();
            addScore.Raise(pointsForStunning);
        }
    }
예제 #7
0
 private void Start()
 {
     mGrenadedLogic        = GetComponent <AI_GrenadedLogic>();
     mConResults           = GetComponent <TNK_Conditions>();
     mChargeLogic          = GetComponent <AI_ChargeLogic>();
     mAttackFromRangeLogic = GetComponent <AI_AttackFromRange>();
     mAnim = UT_FindComponent.FindComponent <AN_Enemies>(gameObject);
 }
예제 #8
0
 private void Awake()
 {
     mEntity   = GetComponent <AI_Controller>();
     mOrienter = GetComponent <AI_Orienter>();
     mRigid    = GetComponent <Rigidbody>();
     mAnim     = UT_FindComponent.FindComponent <AN_Enemies>(gameObject);
     mMover    = GetComponent <AI_MoveToGoal>();
 }
예제 #9
0
 // This used to be more complicated.
 void OnTriggerEnter(Collider other)
 {
     // Hack this in.
     if (UT_FindComponent.FindComponent <Bullet>(other.gameObject))
     {
         mHealth -= 10f;
     }
 }
예제 #10
0
 private void Start()
 {
     mGrenadedLogic     = GetComponent <AI_GrenadedLogic>();
     mConResults        = GetComponent <GRT_Conditions>();
     mAttackRangedLogic = GetComponent <AI_AttackFromRange>();
     mRetreatLogic      = GetComponent <AI_Retreat>();
     mAnim     = UT_FindComponent.FindComponent <AN_Enemies>(gameObject);
     mFlyLogic = GetComponent <AI_FlyLogic>();
 }
예제 #11
0
 private void Start()
 {
     mGrenadedLogic        = GetComponent <AI_GrenadedLogic>();
     mConResults           = GetComponent <LNK_Conditions>();
     mStrafer              = GetComponent <AI_Strafer>();
     mAttackFromRangeLogic = GetComponent <AI_AttackFromRange>();
     mAnim   = UT_FindComponent.FindComponent <AN_Enemies>(gameObject);
     mShield = GetComponentInChildren <EnemyForceField>();
 }
예제 #12
0
 private void Awake()
 {
     mEntity   = GetComponent <AI_Controller>();
     mCons     = GetComponent <AI_Conditions>();
     mOrienter = GetComponent <AI_Orienter>();
     mStrafer  = GetComponent <AI_Strafer>();
     mGun      = GetComponentInChildren <WP_Gun>();
     mRigid    = GetComponent <Rigidbody>();
     mAnim     = UT_FindComponent.FindComponent <AN_Enemies>(gameObject);
 }
예제 #13
0
	// maybe we spawn up some walls or something like that.
	// We definitely spawn some enemies.
	public void OnRoomEntered(){
		if(mRoomEntered) return;

		mRoomEntered = true;
		// now do the stuff.

		for(int i=0; i<mTurrets.Length; i++){
			if(mTurrets[i] == null){
				var clone = Instantiate(mTurPrefab, mSpawnPoints[i].transform.position, mSpawnPoints[i].transform.rotation);
				mTurrets[i] = UT_FindComponent.FindComponent<AI_Turret>(clone.gameObject);
			}
		}
	}
예제 #14
0
    private void Start()
    {
        mMeleeHitBox = UT_FindComponent.FindComponent <TNK_MeleeBox>(gameObject);
        mMeleeHitBox.gameObject.SetActive(false);

        mEntity   = GetComponent <AI_Controller>();
        mOrienter = GetComponent <AI_Orienter>();
        mRigid    = GetComponent <Rigidbody>();
        mAnim     = UT_FindComponent.FindComponent <AN_Enemies>(gameObject);
        mCannon   = UT_FindComponent.FindComponent <WP_TankGun>(gameObject);
        mMover    = GetComponent <AI_Mover>();

        mCachedDir = new Vector3();
    }
예제 #15
0
 // ONLY CALL WHEN CHECKPOINT RESET.
 // Have side effect of killing all enemies that are still alive.
 public void ResetWave()
 {
     CleanEnemiesList();
     for (int i = 0; i < mEnemies.Count; i++)
     {
         AI_Controller mEnemyPointer = UT_FindComponent.FindComponent <AI_Controller>(mEnemies[i].gameObject);
         if (mEnemyPointer != null)
         {
             mEnemyPointer.KillYourself();
         }
     }
     mEnemies.Clear();
     mNumSpawned      = 0;
     mNumThatHaveDied = 0;
     mTimeLeft        = mWave.mTime;
     mSpawnedArrows   = false;
 }
예제 #16
0
    void OnCollisionEnter(Collision collision)
    {
        if (mGrounded)
        {
            return;
        }

        EN_FieldGround field = UT_FindComponent.FindComponent <EN_FieldGround>(collision.gameObject);

        if (field != null)
        {
            TDC_EventManager.FBroadcast(TDC_GE.GE_BallHitGround);
            mGrounded = true;
            FX_Football s = Instantiate(PF_PartAndSFX, transform.position, transform.rotation);
            s.mClunk.Play();
        }
    }
예제 #17
0
    // Needs to check that it hit something that can destroy it, which is basically everthing.
    private void OnTriggerEnter(Collider other)
    {
        EnemyForceField forceField = other.GetComponent <EnemyForceField>();

        if (forceField != null)
        {
            forceField.TakeDamage(forceField.health);
            Explode();
        }

        DestroyObjectOnCollision dBul = UT_FindComponent.FindComponent <DestroyObjectOnCollision>(other.gameObject);
        AI_Controller            npc  = UT_FindComponent.FindComponent <AI_Controller>(other.gameObject);

        if (npc != null || dBul != null)
        {
            Explode();
        }
    }
예제 #18
0
    // This will be called by the NPC that owns this weapon
    public override void TryToFireGun(Transform victim)
    {
        if (!UT_FindComponent.FindComponent <AI_Controller>(gameObject).GetBase().mCanFireGun)
        {
            mFireTimeStamp = Time.time;
            return;
        }

        target      = victim.position;
        victimTrans = victim;
        // target = victimPos;
        isActivated = true;
        // Can't idle any longer, but don't change state as opposed to that.
        if (state == WeaponState.IDLE)
        {
            state = WeaponState.CHARGING;
        }
    }
예제 #19
0
    private void Awake()
    {
        if (UT_FindComponent.FindComponent <GRT_Behaviour>(gameObject) != null)
        {
            mType = EnemyTypes.GRUNT;
        }
        else if (UT_FindComponent.FindComponent <LNK_Behaviour>(gameObject) != null)
        {
            mType = EnemyTypes.LANKY;
        }
        else if (UT_FindComponent.FindComponent <TNK_Behaviour>(gameObject) != null)
        {
            mType = EnemyTypes.TANK;
        }
        else
        {
        }

        mCont = UT_FindComponent.FindComponent <AI_Controller>(gameObject);
    }
예제 #20
0
    /************************************************************************************************
    *  Each individual weapon will define how it fires its projectile.
    *  By the time this has been called we are sure that we are firing the weapon. We have already checked
    *  that we are loaded, charged, and nothing else is preventing us from firing.
    *
    *  Great opportunity to use Carlos's Event system.
    ************************************************************************************************/
    protected virtual void FireProjectile(Transform trans)
    {
        mFireTimeStamp = Time.time;

        // our plasma ray gun is as basic as it gets, spawning a plasmoid and then trying to re-chamber.
        // The target has already been set, and the projectile now simply has to have force added in the direction
        Vector3 dir = Vector3.Normalize(trans.position - transform.position);

        // GameObject clone = PhotonNetwork.Instantiate(mGunProperties.bullet.name, transform.position, Quaternion.LookRotation(dir, Vector3.up));
        dir = CalculateRandomError(dir);
        GameObject    clone = Instantiate(mRegGunProperties.bullet, firePoint.position, Quaternion.LookRotation(dir, Vector3.up));
        AI_Controller owner = UT_FindComponent.FindComponent <AI_Controller>(gameObject);

        if (owner != null)
        {
            clone.GetComponent <Bullet>().SetOwner(owner.transform);
        }
        else
        {
            clone.GetComponent <Bullet>().SetOwner(transform);
        }
        clone.GetComponent <Bullet>().SetTarget(trans);

        // Also, got to create those particles for the muzzle blast
        if (mGunProperties.mMuzzleBlast)
        {
            var mBlast = Instantiate(mGunProperties.mMuzzleBlast, firePoint.transform.position, transform.rotation);
        }

        for (int i = 0; i < mGunProperties.mSwitchGroups.Length; i++)
        {
            AUD_Manager.SetSwitch(mGunProperties.mSwitchGroups[i], mGunProperties.mSwitchStates[i], gameObject);
        }
        AUD_Manager.PostEvent(mGunProperties.mAudFireEvent, gameObject);

        // play the dialogue for our character shooting.
        AUD_Manager.DynamicDialogueFromData(owner.GetBase().mShootLine, gameObject);

        // Now push the event that a weapon has fired.
        owner.GetBase().mEnemyFired.Raise(null);
    }
예제 #21
0
    private void Update()
    {
        base.Update();

        // the text of the button MUST match the text for the difficulty select.
        if (input.aButtonPressed)
        {
            Text btTxt = UT_FindComponent.FindComponent <Text>(mButtons[mActive].gameObject);

            DifficultyValue.Value = btTxt.text;

            MN_Manager.Instance.ShowScreen <MN_LvlSelect>();
            Events.OnButtonPress.Raise(null);
        }

        // If they press b, go back to the main menu.
        if (input.bButtonPressed)
        {
            Events.OnBackScreen.Raise(null);
            MN_Manager.Instance.ShowScreen <MN_CharSelect>();
        }
    }
예제 #22
0
    void OnTriggerEnter(Collider other)
    {
        PRAC_Off_Ply p = UT_FindComponent.FindComponent <PRAC_Off_Ply>(other.gameObject);

        if (p != null)
        {
            if (p.mState != PRAC_Ath.PRAC_ATH_STATE.STACKLED)
            {
                Debug.Log(p.mState);
                if (p == cAth.rMan.FGetBallCarrier())
                {
                    Debug.Log("Tackle the offensive player");
                    p.FENTER_Tackled();
                    TDC_EventManager.FBroadcast(TDC_GE.GE_Tackled);
                }
                else
                {
                    Debug.Log("Wasn't the ball carrier");
                }
            }
        }
    }
예제 #23
0
 private void Awake()
 {
     owner = UT_FindComponent.FindComponent <AI_Controller>(gameObject);
 }
예제 #24
0
 private void Awake()
 {
     mHealthBar = UT_FindComponent.FindComponent <UI_HealthBarEnemy>(gameObject);
 }
예제 #25
0
 private void Awake()
 {
     mEntity    = UT_FindComponent.FindComponent <AI_Controller>(gameObject);
     mGrenLogic = UT_FindComponent.FindComponent <AI_GrenadedLogic>(gameObject);
 }
예제 #26
0
 private void Awake()
 {
     mGun = UT_FindComponent.FindComponent <WP_Gun>(gameObject);
 }
예제 #27
0
 private void Awake()
 {
     mAnimController = GetComponent <Animator>();
     mEntity         = UT_FindComponent.FindComponent <AI_Controller>(gameObject);
     mGun            = UT_FindComponent.FindComponent <WP_Gun>(gameObject);
 }
예제 #28
0
 private void Awake()
 {
     mTurretComp = UT_FindComponent.FindComponent <AI_Turret>(gameObject);
 }