Inheritance: MonoBehaviour
 public     /// <summary>
 /// Start is called on the frame when a script is enabled just before
 /// any of the Update methods is called the first time.
 /// </summary>
 void Start()
 {
     PlayerAnimator  = model.GetComponent <Animator>();
     AttackBehaviour = PlayerAnimator.GetBehaviour <AttackBehaviour>();
     AttackBehaviour.OnProjectileAttackStartedEvent += OnProjectileShouldBeInstantiated;
     AttackBehaviour.OnProjectileFireEvent          += OnProjectileShouldBeFired;
 }
Exemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     curWeapon = pController.curWeapon;
     rb2D      = GetComponent <Rigidbody2D>();
     anim      = GetComponentInChildren <Animator>();
     sprite    = GetComponentInChildren <SpriteRenderer>();
 }
Exemplo n.º 3
0
 override protected void Awake()
 {
     base.Awake();
     movementBehaviour   = GetComponent <MovementBehaviour>();
     attackBehaviour     = GetComponent <AttackBehaviour>();
     TimeManager.OnTick += OnTick;
 }
Exemplo n.º 4
0
 public void SetSpell()
 {
     if (Input.GetKeyDown(KeyCode.Alpha1))
     {
         //Debug.Log("0");
         curWeapon = attackList[0];
     }
     else if (Input.GetKeyDown(KeyCode.Alpha2))
     {
         //Debug.Log("1");
         curWeapon = attackList[1];
     }
     else if (Input.GetKeyDown(KeyCode.Alpha3))
     {
         //Debug.Log("2");
         curWeapon = attackList[2];
     }
     else if (Input.GetKeyDown(KeyCode.Alpha4))
     {
         //Debug.Log("3");
         curWeapon = attackList[3];
     }
     else if (Input.GetKeyDown(KeyCode.Alpha5))
     {
         //Debug.Log("4");
         curWeapon = attackList[4];
     }
 }
Exemplo n.º 5
0
 private void OnDieHandler()
 {
     UserInfo.KillEnemy();
     MeshRenderer.material.color = DieColor;
     AttackBehaviour.Untarget();
     Target = null;
 }
Exemplo n.º 6
0
 public AttackController(Transform owner, AttackBehaviour attackBehaviour, TransformList enemiesList)
 {
     this.owner           = owner;
     this.attackBehaviour = attackBehaviour;
     this.enemiesList     = enemiesList;
     targets = new Transform[attackBehaviour.TargetLimit];
 }
Exemplo n.º 7
0
 public void Awake()
 {
     _moveBehaviour   = GetComponent <MoveBehaviour>();
     _animator        = GetComponent <Animator>();
     _spriteRenderer  = GetComponent <SpriteRenderer>();
     _attackBehaviour = GetComponent <AttackBehaviour>();
     _trailBehaviour  = GetComponent <TrailBehaviour>();
 }
Exemplo n.º 8
0
 public void Awake()
 {
     _moveBehaviour   = GetComponent <MoveBehaviour>();
     _animator        = GetComponent <Animator>();
     _spriteRenderer  = GetComponent <SpriteRenderer>();
     _attackBehaviour = GetComponent <AttackBehaviour>();
     _audioSource     = GetComponent <AudioSource>();
 }
Exemplo n.º 9
0
    public void Initialize()
    {
        attack   = GetComponent <AttackBehaviour> ();
        target   = GetComponent <TargetBehaviour> ();
        movement = GetComponent <MovementBehaviour> ();
        evade    = GetComponent <EvadeBehaviour> ();

        individual = GetComponent <Individual> ();
    }
Exemplo n.º 10
0
 public void Awake()
 {
     DontDestroyOnLoad(this.gameObject);
     _moveBehaviour   = GetComponent <MoveBehaviour>();
     _animator        = GetComponent <Animator>();
     _spriteRenderer  = GetComponent <SpriteRenderer>();
     _attackBehaviour = GetComponent <AttackBehaviour>();
     _trailBehaviour  = GetComponent <TrailBehaviour>();
 }
 void Awake()
 {
     animator        = GetComponent <Animator>();
     rbody           = GetComponentInParent <Rigidbody>();
     physics         = GetComponentInParent <PlayerPhysics>();
     attackbehaviour = GetComponentInParent <AttackBehaviour>();
     deadbehaviour   = GetComponentInParent <DeadBehaviour>();
     rotationY       = Quaternion.Euler(0, 90, 0);
 }
Exemplo n.º 12
0
    protected virtual void OnDisable()
    {
        // unsubscribe from OnAttack
        AttackBehaviour attackBehaviour = GetComponent <AttackBehaviour>();

        if (attackBehaviour != null)
        {
            attackBehaviour.OnAttack -= HandleOnAttack;
        }
    }
Exemplo n.º 13
0
    protected virtual void OnEnable()
    {
        // subscribe to OnAttack
        AttackBehaviour attackBehaviour = GetComponent <AttackBehaviour>();

        if (attackBehaviour != null)
        {
            attackBehaviour.OnAttack -= HandleOnAttack;
            attackBehaviour.OnAttack += HandleOnAttack;
        }
    }
Exemplo n.º 14
0
    private AttackBehaviour SearchList(AttackBehaviour attackBehaviour)
    {
        foreach (AttackBehaviour attBehaviour in pController.attackList)
        {
            if (attackBehaviour == attBehaviour)
            {
                return(attBehaviour);
            }
        }

        return(null);
    }
Exemplo n.º 15
0
    private void OnEnable()
    {
        m_environment = GameEnvironment.CreateInstance(BoardManager.GetMap(), new List <Tile>()
        {
            Tile.Wall, Tile.BreakableWall, Tile.Reflector
        });
        m_searchBehaviour = GetComponent <SearchBehaviour>();
        m_attackBehaviour = GetComponent <AttackBehaviour>();
        m_sonarBehaviour  = GetComponent <SonarBehaviour>();

        m_searchBehaviour.Environment = m_environment;
        m_attackBehaviour.Environment = m_environment;
    }
Exemplo n.º 16
0
        private void AttackTypeChanged()
        {
            switch (attackType)
            {
            case AttackType.SingleTarget:
                selectedAttack = CreateInstance <SingleAttackBehaviour>();
                break;

            case AttackType.AreaOfEffect:
                selectedAttack = CreateInstance <AreaAttackBehaviour>();
                break;
            }
        }
Exemplo n.º 17
0
        public void Initialize(int shatterAmount, float jumpRadius, float damageReductionOnShatter, AttackBehaviour shatterAttackBehaviour, TransformList enemiesAlive)
        {
            this.shatterAmount            = shatterAmount;
            this.damageReductionOnShatter = damageReductionOnShatter;
            this.jumpRadius             = jumpRadius;
            this.shatterAttackBehaviour = shatterAttackBehaviour;
            this.enemiesAlive           = enemiesAlive;

            projectile = GetComponent <Projectile>();
            projectile.SetDeathBehaviour(this);
            currentTarget = projectile.Target;

            initialized = true;
        }
Exemplo n.º 18
0
 private void Attack(GameObject enemy, string enemyType)
 {
     if (!attackCooldownActive)
     {
         string     attackType   = GetAttackType(enemyType);
         GameObject attackPrefab = GetAttack(attackType);
         if (attackPrefab)
         {
             AttackBehaviour attack = (Instantiate(attackPrefab) as GameObject).GetComponent <AttackBehaviour>();
             attack.SetObjectType(attackType);
             attack.MoveTowards(enemy);
         }
         StartCoroutine(AttackCooldown());
     }
 }
Exemplo n.º 19
0
    private void Start()
    {
        var playerData2 = Instantiate(playerData);

        playerData = playerData2;
        rig        = GetComponent <Rigidbody2D>();
        spriteRend = GetComponentInChildren <SpriteRenderer>();
        SetAttackMode(false);
        inputControl    = GetComponent <InputControl>();
        attackComponent = GetComponent <AttackBehaviour>();
        anim            = GetComponent <Animator>();
        lookingRight    = true;
        psDust.Stop();
        Item.ChickenConsumed += TurnIntoChicken;
        aSource = GetComponent <AudioSource>();
        AudioManager.Get().AddSound(aSource);
    }
Exemplo n.º 20
0
 private void LateUpdate()
 {
     if (Target)
     {
         if ((Agent.transform.position - Target.transform.position).magnitude < DistanceToTarget)
         {
             AttackBehaviour.Attack(Target);
         }
         else
         {
             Agent.SetDestination(Target.transform.position);
         }
     }
     else if (AttackBehaviour.IsAttackTarget)
     {
         AttackBehaviour.Untarget();
     }
 }
Exemplo n.º 21
0
    void Awake()
    {
        physics         = GetComponent <PlayerPhysics>();
        controller      = GetComponent <PlayerController>();
        grapplingGun    = GetComponent <GrapplingGun>();
        attackbehaviour = GetComponent <AttackBehaviour>();
        deadbehaviour   = GetComponent <DeadBehaviour>();

        physics.player = this;

        controller.physics         = physics;
        controller.grapplingGun    = grapplingGun;
        controller.attackBehaviour = attackbehaviour;
        controller.deadbehaviour   = deadbehaviour;

        grapplingGun.physics = physics;

        attackbehaviour.physics = physics;
    }
Exemplo n.º 22
0
    private static bool Attack(BoardPlayer player, Card actorCard, Card targetCard)
    {
        // I cannot attack on my own minions
        if (targetCard.owner == actorCard.owner)
        {
            return(false);
        }

        AttackBehaviour ab = actorCard.gameObject.AddComponent <AttackBehaviour>();

        ab.TargetCard       = targetCard;
        ab.ActorCard        = actorCard;
        ab.Player           = player;
        ab.MovingCardCanvas = player.GameManager.MovingCardCanvas;
        ab.Initialize(player.GameManager.ActionManager.AttackBehaviourConstants);


        return(true);
    }
Exemplo n.º 23
0
    //Unity functions

    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            DestroyImmediate(gameObject);
        }

        startScale = waves[0].transform.localScale;
        foreach (GameObject wave in waves)
        {
            wave.SetActive(false);
        }
        for (int i = 0; i < waves.Length; i++)
        {
            movements[i] = waves[i].GetComponent <WaveMovement>();
        }
    }
Exemplo n.º 24
0
    private void Start()
    {
        if (playerStat == null)
        {
            Active = false;
            Debug.LogError("No PlayerStat on Player Controller Object");
        }
        attackBehaviour    = transform.GetChild(0).gameObject.GetComponent <AttackBehaviour>();
        movementController = this.GetComponent <MovementController>();
        if (movementController == null)
        {
            Active = false;
            Debug.LogError("No MovementController on Player Controller Object");
            return;
        }
        attackAnimator = this.GetComponentInChildren <Animator>();

        shipPartsPooler              = this.gameObject.AddComponent <Pooler>();
        shipPartsPooler.startAmount  = 2;
        shipPartsPooler.PooledObject = shiptSpritePartPrefab;
    }
Exemplo n.º 25
0
    public void Attack()
    {
        curWeapon = pController.curWeapon;
        if (curWeapon != null)
        {
            if (Input.GetMouseButtonDown(0) && !SearchList(curWeapon).inCd)
            {
                attacking = true;
                //Debug.Log(curWeapon);
                if (source.isPlaying)
                {
                    source.clip = attackSound[Random.Range(0, attackSound.Count)];
                    source.Play();
                }

                cd     = curWeapon.cooldownTime;
                damage = curWeapon.damage;
                SearchList(curWeapon).inCd = true;
                StartCoroutine("AttackCo");
            }
        }
    }
Exemplo n.º 26
0
        /// <summary>
        /// Pick the next target.
        /// </summary>
        private void PickTarget()
        {
            if (Body.IsIncapacitated)
            {
                return;
            }

            GameLiving target = Aggression.PrimaryTarget;

            if (target == null)
            {
                AttackBehaviour.Retreat();
                Aggression.Clear();
                Body.TargetObject = null;
                AttackBehaviour   = PassiveBehaviour;
                Body.WalkToSpawn();
            }
            else
            {
                if (AttackBehaviour is PassiveBehaviour)
                {
                    AttackBehaviour = (Body.CanCastHarmfulSpells)
                        ? CastingBehaviour
                        : MeleeBehaviour;
                }
                else
                {
                    if (AttackBehaviour is MeleeBehaviour)
                    {
                        if (Body.CanCastHarmfulSpells && Util.Chance(Properties.GAMENPC_CHANCES_TO_CAST))
                        {
                            AttackBehaviour = CastingBehaviour;
                        }
                    }
                }

                AttackBehaviour.Attack(target);
            }
        }
Exemplo n.º 27
0
 protected override void init()
 {
     BaseStats = new Stats((int)EnemyStats.x, (int)EnemyStats.y);
     attack    = GetComponent <AttackBehaviour>();
 }
Exemplo n.º 28
0
 public void GetStun(float stn)
 {
     //		rb2d.velocity = Vector2.zero;
     myBehaviour = AttackBehaviour.Stunned;
     stunTimer = stn;
 }
Exemplo n.º 29
0
    // Update is called once per frame
    void Update()
    {
        if(attackTimer > 0)attackTimer -= Time.deltaTime;

        switch (myBehaviour)
        {
        case AttackBehaviour.Melee:

            break;

        case AttackBehaviour.Range:
            isPlayerInRange = Physics2D.OverlapCircle(transform.position, aggroRange, playerLayer);

            if(attackTimer <= 0 && isPlayerInRange)
            {
                if (GetComponent<Animator>() != null)
                {
                    enemyAnim = FindObjectOfType<EnemyAnimation>();
                    if(gameObject.name == "Ranged Sound Ninja" || gameObject.name == "Spawning Ranged Sound Ninja")
                    {
                        attackAnimation = true;
                        return;
                    }
                }
                else
                {
                    enemyAnim = null;
                }
                //GizmoAttack.Play ();
                aiming = player.transform.position - transform.position;
                attackTimer = timeBetweenAttacks;
                temp = Instantiate(projectile);
                trf = temp.GetComponent<Transform>();
                trf.position = transform.position;
                rb2d = temp.GetComponent<Rigidbody2D>();
                rb2d.velocity = aiming.normalized*projectileSpeed;
            }
            break;

        case AttackBehaviour.Bomber:
            if(attackTimer <= 0){
                attackTimer = timeBetweenAttacks;
                temp = Instantiate(projectile);
                trf = temp.GetComponent<Transform>();
                trf.position = transform.position;
                rb2d = temp.GetComponent<Rigidbody2D>();
                rb2d.velocity = new Vector2(0,-projectileSpeed);
            }
            break;

        case AttackBehaviour.SideBomber:
            if(attackTimer <= 0){
                attackTimer = timeBetweenAttacks;
                temp = Instantiate(projectile);
                trf = temp.GetComponent<Transform>();
                trf.position = transform.position;
                rb2d = temp.GetComponent<Rigidbody2D>();
                if(shootingLeft)
                    rb2d.velocity = new Vector2(-projectileSpeed,0);
                else
                    rb2d.velocity = new Vector2(projectileSpeed,0);
            }
            break;

        case AttackBehaviour.Stunned:
            stunTimer -= Time.deltaTime;
            if(stunTimer <=0 ){
                myBehaviour = myDefaultBehaviour;
            }
            break;
        }
    }
Exemplo n.º 30
0
    // Use this for initialization
    void Start()
    {
        if (GetComponent<EnemyAnimation>() != null)
        {
            enemyAnim = FindObjectOfType<EnemyAnimation>();
        }
        else
        {
            enemyAnim = null;
        }
        attackAnimation = false;
        myBehaviour = myDefaultBehaviour;
        playerSound = GameObject.Find("Player").GetComponent<AudioSource>();
        playerScript = GameObject.Find ("Player").GetComponent<MasterController> ();
        player = GameObject.Find ("Player");
        //GizmoAttack = GetComponent<AudioSource> ();

        if(Application.loadedLevel == 9)
        {
            sasuke = FindObjectOfType<SasukeController>();
        }
    }
Exemplo n.º 31
0
 void Awake()
 {
     agent    = GetComponent <NavMeshAgent>();
     animator = GetComponentInChildren <Animator>();
     attack   = GetComponent <AttackBehaviour>();
 }
Exemplo n.º 32
0
 public void Attack()
 {
     AttackBehaviour.Attack();
 }
Exemplo n.º 33
0
 void Awake()
 {
     attack = GetComponent<AttackBehaviour>();
     if (attack != null)
         attacking = true;
 }
Exemplo n.º 34
0
    void Start()
    {
        //VARIABLES
        lookB         = GetComponent <LookAroundBehaviour>();
        patrolB       = GetComponent <PatrolBehaviour>();
        chaseB        = GetComponent <ChaseBehaviour>();
        atkB          = GetComponent <AttackBehaviour>();
        coneVision    = GetComponent <ConeVision>();
        fsmCurrentTxt = fsmCurrentTxt.GetComponent <TextMeshProUGUI>();
        velocity      = GetComponent <Velocity>();
        health        = GetComponent <HealthBar>();

        //STATES
        FSMState Start        = new FSMState();
        FSMState lookAround   = new FSMState();
        FSMState patrol       = new FSMState();
        FSMState lastPosition = new FSMState();
        FSMState chase        = new FSMState();
        FSMState attack       = new FSMState();


        //ACTIONS
        Start.enterActions.Add(StartAction);

        lookAround.enterActions.Add(LookAround);
        lookAround.exitActions.Add(lookB.StopLooking);

        patrol.enterActions.Add(Patrol);
        patrol.exitActions.Add(patrolB.StopPatrol);

        chase.enterActions.Add(Chase);
        chase.exitActions.Add(chaseB.StopAtLastKnowPosition);

        lastPosition.enterActions.Add(LastPosition);

        attack.enterActions.Add(chaseB.StopNow);
        attack.enterActions.Add(Attack);
        attack.exitActions.Add(atkB.StopAttacking);

        //TRANSITIONS
        FSMTransition t0 = new FSMTransition(AlwaysTrue);
        FSMTransition t1 = new FSMTransition(PlayerHidden);
        FSMTransition t2 = new FSMTransition(PlayerDetected);
        FSMTransition t3 = new FSMTransition(PlayerNotDetected);
        FSMTransition t4 = new FSMTransition(PlayerInAttackRange);
        FSMTransition t5 = new FSMTransition(PlayerNotInAttackRange);
        FSMTransition t6 = new FSMTransition(PatrolingFinished);
        FSMTransition t7 = new FSMTransition(NotMoving);
        FSMTransition t8 = new FSMTransition(PlayerNotHidden);

        //LINK STATE - TRANSITION
        Start.AddTransition(t0, patrol);

        lookAround.AddTransition(t1, patrol);
        lookAround.AddTransition(t8, chase);
        lookAround.AddTransition(t2, chase);

        patrol.AddTransition(t2, chase);
        patrol.AddTransition(t6, lookAround);

        chase.AddTransition(t3, lastPosition);
        chase.AddTransition(t4, attack);

        lastPosition.AddTransition(t7, lookAround);
        lastPosition.AddTransition(t2, chase);

        attack.AddTransition(t5, chase);

        //INITIAL STATE
        fsm = new FSM(Start);
        StartCoroutine(Run());
    }