void Start()
 {
     shakeCamera     = FindObjectOfType <ShakeCamera>();
     cameraFollow    = FindObjectOfType <CameraFollow>();
     characterAttack =
         GameObject.FindGameObjectWithTag(Tags.PLAYER).GetComponent <CharacterAttackController>();
 }
示例#2
0
    void Awake()
    {
        if (isPlayer)
        {
            _playerController   = GetComponent <CharacterAttackController>();
            _playerMovement     = GetComponent <CharacterMovement>();
            _rigidbody          = GetComponent <Rigidbody>();
            _shootingController = GetComponent <ShootingController>();
        }
        if (isEnemy)
        {
            _enemyController = GetComponent <EnemyController>();
            _navMeshAgent    = GetComponent <NavMeshAgent>();
        }

        if (isViper)
        {
            _navMeshAgent    = GetComponent <NavMeshAgent>();
            _enemyAudio      = GetComponent <AudioSource>();
            _viperController = GetComponent <TheViperController>();
        }



        _animations = GetComponent <CharacterAnimations>();
    }
示例#3
0
 void Start()
 {
     timeJumpPressed      = 0;
     character            = GetComponent <PlayerController>();
     characterGravityBody = character.GetComponent <SpaceGravityBody> ();
     attackController     = GetComponent <CharacterAttackController> ();
     WeaponManager wpm = WeaponManager.Instance;
 }
示例#4
0
    public override void DoBehavior(CharacterAttackController controller)
    {
        Vector2 target = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        if (ShouldUseWeapon())
        {
            controller.Attack(target);
        }
    }
示例#5
0
    public override void DoBehavior(CharacterAttackController controller)
    {
        List <Collider2D> possibleTargets = new List <Collider2D>();

        Vector2 selfPosition = controller.transform.position;

        Team selfTeam = controller.GetComponent <TeamAssigner>().team;

        foreach (Collider2D collider in Physics2D.OverlapCircleAll(selfPosition, attackRadius))
        {
            TeamAssigner assigner = collider.GetComponent <TeamAssigner>();
            if (assigner != null && selfTeam != assigner.team)
            {
                possibleTargets.Add(collider);
            }
        }

        float      closestDistance = Mathf.Infinity;
        Collider2D closestTarget   = null;

        foreach (Collider2D possibleTarget in possibleTargets)
        {
            // Check if we have line of sight
            Vector2 targetPosition = possibleTarget.transform.position;
            Vector2 direction      = targetPosition - selfPosition;
            float   distance       = direction.magnitude;

            bool lineOfSight = true;
            foreach (RaycastHit2D hit in Physics2D.RaycastAll(controller.transform.position, direction, distance))
            {
                if (hit.collider.gameObject.GetComponent <VisionOccluder>() != null)
                {
                    lineOfSight = false;
                }
            }

            if (lineOfSight && distance <= closestDistance)
            {
                closestTarget   = possibleTarget;
                closestDistance = distance;
            }
        }

        if (closestTarget != null)
        {
            controller.Attack(closestTarget.transform.position);
        }
    }
示例#6
0
    void Start()
    {
        body                = GetComponent <SpaceGravityBody> ();
        killable            = GetComponent <Killable> ();
        characterController = GetComponent <CharacterController> ();
        attackController    = GetComponent <CharacterAttackController> ();
        GameObject attack = GameObject.Find("skillAttack");

        initializePlayerRotation();
        bpAnimator        = animationBigPappada.GetComponent <Animator>();
        pappadaC          = pappada.GetComponent <PappadaController> ();
        flyParticles      = flyingParticles.GetComponent <ParticleSystem> ();
        getHurtBigPappada = GameObject.Instantiate(getHurtBigPappadaPrefab) as GameObject;
        initializeVariables();
        StartCoroutine("resetWeaponTrail");
    }
示例#7
0
    // Use this for initialization
    void Start()
    {
        if (!isForCinematic)
        {
            GameManager.iaManager.registerIA(this);
        }
        despawned            = false;
        attackController     = GetComponent <CharacterAttackController> ();
        isOnGuard            = false;
        iaAnimator           = GetComponentInChildren <Animator> ();
        player               = GameManager.player;
        characterController  = GetComponent <CharacterController> ();
        transform.forward    = new Vector3(1f, 0f, 0f);
        minimumDistanceFront = ((Random.value) * 0.2f) + 0.2f;

        isDead = false;
        walkOnMultiplePaths = GetComponent <WalkOnMultiplePaths> ();

        enemyOnHitParticlesController = GetComponent <EnemyOnHitParticlesController> ();
        //Particle Inicialization
        //hitParticles = new GameObject[3];

        //hitParticles[0] = GameObject.Instantiate (onHitEffect) as GameObject;
        //hitParticles[1] = GameObject.Instantiate (secondOnHitEffect) as GameObject;
        //hitParticles[2] = GameObject.Instantiate (thirdOnHitEffect) as GameObject;
        flyParticles = GameObject.Instantiate(flySmokeParticles) as GameObject;
        flyParticles.transform.parent   = transform;
        flyParticles.transform.position = GetComponent <Rigidbody> ().worldCenterOfMass;
        hitGroundParticles = GameObject.Instantiate(onHitGroundParticles) as GameObject;
        hitGroundParticles.transform.parent   = transform;
        hitGroundParticles.transform.position = GetComponent <Rigidbody> ().worldCenterOfMass;

        /*foreach (GameObject particles in hitParticles) {
         *      particles.transform.parent = gameObject.transform;
         * }*/
    }
 void Start()
 {
     body = GetComponent<SpaceGravityBody> ();
     killable = GetComponent<Killable> ();
     characterController = GetComponent<CharacterController> ();
     attackController = GetComponent<CharacterAttackController> ();
     GameObject attack = GameObject.Find("skillAttack");
     initializePlayerRotation ();
     bpAnimator = animationBigPappada.GetComponent<Animator>();
     pappadaC = pappada.GetComponent<PappadaController> ();
     flyParticles = flyingParticles.GetComponent<ParticleSystem> ();
     getHurtBigPappada = GameObject.Instantiate (getHurtBigPappadaPrefab) as GameObject;
     initializeVariables ();
     StartCoroutine ("resetWeaponTrail");
 }
示例#9
0
 public override void DrawAttackGizmos(CharacterAttackController controller)
 {
     base.DrawAttackGizmos(controller);
     Gizmos.color = Color.red;
     Gizmos.DrawWireSphere(controller.transform.position, attackRadius);
 }
示例#10
0
文件: Weapon.cs 项目: jono-m/GameJams
 public virtual void DrawAttackGizmos(CharacterAttackController controller)
 {
 }
示例#11
0
文件: Weapon.cs 项目: jono-m/GameJams
 public abstract void Use(CharacterAttackController attackController, Vector2 target);
 private void Awake()
 {
     character        = FindObjectOfType <CharacterAttackController>();
     healthController = GameObject.FindGameObjectWithTag(Tags.ENEMY).GetComponent <UniversalHealthController>();
     animations       = GameObject.FindGameObjectWithTag(Tags.ENEMY).GetComponent <CharacterAnimations>();
 }
    // Use this for initialization
    void Start()
    {
        if(!isForCinematic){
            GameManager.iaManager.registerIA (this);
        }
        despawned = false;
        attackController = GetComponent<CharacterAttackController> ();
        isOnGuard = false;
        iaAnimator = GetComponentInChildren<Animator> ();
        player = GameManager.player;
        characterController = GetComponent<CharacterController> ();
        transform.forward = new Vector3(1f,0f,0f);
        minimumDistanceFront = ((Random.value)*0.2f) + 0.2f;

        isDead = false;
        walkOnMultiplePaths = GetComponent<WalkOnMultiplePaths> ();

        enemyOnHitParticlesController = GetComponent<EnemyOnHitParticlesController> ();
        //Particle Inicialization
        //hitParticles = new GameObject[3];

        //hitParticles[0] = GameObject.Instantiate (onHitEffect) as GameObject;
        //hitParticles[1] = GameObject.Instantiate (secondOnHitEffect) as GameObject;
        //hitParticles[2] = GameObject.Instantiate (thirdOnHitEffect) as GameObject;
        flyParticles = GameObject.Instantiate (flySmokeParticles) as GameObject;
        flyParticles.transform.parent = transform;
        flyParticles.transform.position = GetComponent<Rigidbody> ().worldCenterOfMass;
        hitGroundParticles = GameObject.Instantiate (onHitGroundParticles) as GameObject;
        hitGroundParticles.transform.parent = transform;
        hitGroundParticles.transform.position = GetComponent<Rigidbody> ().worldCenterOfMass;

        /*foreach (GameObject particles in hitParticles) {
            particles.transform.parent = gameObject.transform;
        }*/
    }
 // Use this for initialization
 //Clase temporal, porque BigP con la animacion debe ser el objeto base, actualmente es
 void Start()
 {
     atkControl = GetComponentInParent<CharacterAttackController>();
 }
示例#15
0
 public abstract void DoBehavior(CharacterAttackController controller);
示例#16
0
 private void Start()
 {
     cac = GetComponent <CharacterAttackController>();
     cmc = GetComponent <CharacterMovementController>();
 }
示例#17
0
 // Start is called before the first frame update
 void Start()
 {
     attackController   = GetComponentInParent <CharacterAttackController>();
     shootingController = GetComponentInParent <ShootingController>();
 }
示例#18
0
    public override void Use(CharacterAttackController attackController, Vector2 target)
    {
        Team firingTeam = attackController.GetComponent <TeamAssigner>().team;

        Vector2 firePoint = attackController.attackBasePoint.transform.position;
        Vector2 delta     = target - firePoint;

        Vector2 fireDirection = delta.normalized;

        bool isRight = delta.x > 0;

        if (autoTarget)
        {
            float sqrtTerm = Mathf.Pow(launchSpeed, 4) - gravity * (gravity * Mathf.Pow(delta.x, 2) + 2 * delta.y * Mathf.Pow(launchSpeed, 2));
            if (sqrtTerm >= 0)
            {
                float sol1 = Mathf.Atan((Mathf.Pow(launchSpeed, 2) + Mathf.Sqrt(sqrtTerm)) / (Mathf.Abs(delta.x * gravity)));
                float sol2 = Mathf.Atan((Mathf.Pow(launchSpeed, 2) - Mathf.Sqrt(sqrtTerm)) / (Mathf.Abs(delta.x * gravity)));

                Vector2 fireDirection1 = new Vector2(Mathf.Cos(sol1) * (isRight ? 1.0f : -1.0f), Mathf.Sin(sol1));
                Vector2 fireDirection2 = new Vector2(Mathf.Cos(sol2) * (isRight ? 1.0f : -1.0f), Mathf.Sin(sol2));

                bool canHit1 = true;
                bool canHit2 = true;

                // Check if we can hit the target without a collision:
                if (Vector2.Angle(attackController.transform.up, fireDirection1) * Mathf.Deg2Rad > upAngleBounds)
                {
                    canHit1 = false;
                }
                else
                {
                    foreach (RaycastHit2D hit in PhysicsUtility.GravityRaycast(firePoint, fireDirection1 * launchSpeed, target, gravity, autoTargetDeltaTime, hitRadius))
                    {
                        if (hit.collider.GetComponent <AutoProjectileBlocker>() != null)
                        {
                            canHit1 = false;
                            break;
                        }
                    }
                }

                if (Vector2.Angle(attackController.transform.up, fireDirection2) * Mathf.Deg2Rad > upAngleBounds)
                {
                    canHit2 = false;
                }
                else
                {
                    foreach (RaycastHit2D hit in PhysicsUtility.GravityRaycast(firePoint, fireDirection2 * launchSpeed, target, gravity, autoTargetDeltaTime, hitRadius))
                    {
                        if (hit.collider.GetComponent <AutoProjectileBlocker>() != null)
                        {
                            canHit2 = false;
                            break;
                        }
                    }
                }

                float?bestAngle = null;

                if (canHit1 && canHit2)
                {
                    float time1 = (launchSpeed * Mathf.Sin(sol1) + Mathf.Sqrt(Mathf.Pow(launchSpeed * Mathf.Sin(sol1), 2) + Mathf.Abs(2 * gravity * delta.y))) / gravity;
                    float time2 = (launchSpeed * Mathf.Sin(sol2) + Mathf.Sqrt(Mathf.Pow(launchSpeed * Mathf.Sin(sol2), 2) + Mathf.Abs(2 * gravity * delta.y))) / gravity;

                    bestAngle = (time1 > time2) ? sol2 : sol1;
                }
                else
                {
                    if (canHit1)
                    {
                        bestAngle = sol1;
                    }
                    else if (canHit2)
                    {
                        bestAngle = sol2;
                    }
                }

                if (bestAngle.HasValue)
                {
                    fireDirection = new Vector2(Mathf.Cos(bestAngle.Value) * (isRight ? 1.0f : -1.0f), Mathf.Sin(bestAngle.Value));
                }
            }
        }

        if (Vector2.Angle(attackController.transform.up, fireDirection) * Mathf.Deg2Rad <= upAngleBounds)
        {
            ProjectileController newProjectile = Instantiate(projectileToFirePrefab.gameObject).GetComponent <ProjectileController>();
            newProjectile.Fire(firePoint, fireDirection, firingTeam, this);
        }
    }
示例#19
0
 public override void DrawAttackGizmos(CharacterAttackController controller)
 {
     base.DrawAttackGizmos(controller);
     Gizmos.DrawLine(controller.transform.position, (Vector2)controller.transform.position + RotateVector(controller.transform.up, upAngleBounds));
     Gizmos.DrawLine(controller.transform.position, (Vector2)controller.transform.position + RotateVector(controller.transform.up, -upAngleBounds));
 }
示例#20
0
    // Use this for initialization
    //Clase temporal, porque BigP con la animacion debe ser el objeto base, actualmente es

    void Start()
    {
        atkControl = GetComponentInParent <CharacterAttackController>();
    }