示例#1
0
文件: RangedAI.cs 项目: nmotocic/PPiJ
 public override void setAlarm(float duration)
 {
     if (state == GameDefaults.hitState())
     {
         duration *= stunMod;
     }
     alarm.setMax(Mathf.Abs(duration));
 }
示例#2
0
        private Game()
        {
            game = this;

            defaults = Resources.Load("GameSettings") as GameDefaults;

            gameStateManager = new StateManagerBase <GameStateBase>();
            RegisterGameStates();
        }
示例#3
0
    // Update is called once per frame
    public void Update()
    {
        attackDelay.Update();
        attackDelay.setMax(parentScript.stats["attackSpeed"].getCompoundValue());
        if (parentScript.stats["health"] != null)
        {
            if (parentScript.stats["health"].getCompoundValue() <= 0)
            {
                death();
            }
        }
        Debug.Log("Hp:" + parentScript.stats["health"].getCompoundValue() + "Delay:" + attackDelay.getTimer() + "/" + attackDelay.getMax());
        float X = Input.GetAxis("Horizontal");
        float Y = Input.GetAxis("Vertical");

        direction = new Vector2(X, Y);
        if (Input.GetMouseButton(0) && attackDelay.isActive() && parentScript.stats["health"].getCompoundValue() > 0)
        {
            Vector2  target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Vector2  position = parentScript.gameObject.transform.position;
            Vector2  shootVector = (target - position).normalized;
            string[] rawInput = { "EFFECT damage boop 1 -1 1" };
            float    angle = 0, diff = 0;
            int      cnter = Mathf.RoundToInt(parentScript.stats["rangedCount"].getCompoundValue());
            if (cnter <= 1)
            { //Barem jedan projektil
                cnter = 1;
            }
            else   //Izracunaj kuteve
            {
                diff        = Mathf.Abs(parentScript.stats["rangedSpread"].getCompoundValue() / (parentScript.stats["rangedCount"].getCompoundValue() - 1));
                angle       = GameDefaults.vectToAngle(shootVector);
                angle      -= Mathf.Abs(parentScript.stats["rangedSpread"].getCompoundValue() / 2);
                shootVector = GameDefaults.angleToVect(angle);
                //Debug.LogWarning("Angle:" + angle.ToString());
            }
            for (int i = 0; i < cnter; i++)
            {
                parentScript.DispenseObject(parentScript.projectileOptions[0], position, shootVector, 20f, rawInput);
                angle += diff;
                //if (cnter % 2 == 0 && cnter==2) angle += diff;
                shootVector = GameDefaults.angleToVect(angle);
                //Debug.LogWarning("ShootVector:" + target.ToString() + "-" + position.ToString() + "=" + shootVector.ToString());
            }
            if (spriteAnimator != null)
            {
                spriteAnimator.attack = true;
            }
            attackDelay.reset();
        }
    }
示例#4
0
 public void getController(string entityType, Vector2 direction, float speed = 0)
 {
     if (direction == null)
     {
         direction = Vector2.zero;
     }
     rb2d = gameObject.GetComponent <Rigidbody2D>();
     if (rb2d == null)
     {
         rb2d = gameObject.AddComponent <Rigidbody2D>();
     }
     if (entityType != null)
     {
         if (entityType.Equals("player"))
         {
             controller = new PlayerController(this, speed);
         }
         else if (entityType.Equals("projectile"))
         {
             controller = new ProjectileController(this, direction, speed);
         }
         else if (entityType.Equals("powerup"))
         {
             controller = new PowerupController(this);
         }
         else if (entityType.Equals("enemy"))
         {
             controller = new EnemyController(this);
         }
     }
     else
     {
         if (gameObject.CompareTag(GameDefaults.Player()))
         {
             controller = new PlayerController(this, speed);
         }
         else if (gameObject.CompareTag(GameDefaults.Projectile()))
         {
             controller = new ProjectileController(this, direction, speed);
         }
         else if (gameObject.CompareTag(GameDefaults.Powerup()))
         {
             controller = new PowerupController(this);
         }
         else if (gameObject.CompareTag(GameDefaults.Enemy()))
         {
             controller = new EnemyController(this);
         }
     }
 }
示例#5
0
文件: RangedAI.cs 项目: nmotocic/PPiJ
 public override void setState(int set)
 {
     if (state != 2 && set == 2)//Despawn
     {
         alarm.reset();
         alarm.setMax(GameDefaults.corpseTimeout());
     }
     state = set;
     if (set == -2)
     {
         agent.enabled = false;
     }
     else
     {
         agent.enabled = true;
     }
 }
示例#6
0
        public static void Open()
        {
            if (editorInstance == null)
            {
                editorInstance = EditorWindow.GetWindow <GameExplorer>();
                editorInstance.titleContent = new GUIContent("GameExplorer");
            }

            GameDefaults settings = FindObjectOfType <GameDefaults>();

            if (settings == null)
            {
                settings = Resources.Load <GameDefaults>("GameSettings");
            }



            //in case a user deleted the settings object
            if (settings == null)
            {
                Debug.LogWarning("Created new instance of gameSettings");
                settings = CreateInstance <GameDefaults>();

                if (!AssetDatabase.IsValidFolder("Assets/Resources"))
                {
                    AssetDatabase.CreateFolder("Assets", "Resources");
                }

                //TODO create this inside Packages/GameplayFramework/GameSettings.asset instead
                AssetDatabase.CreateAsset(settings, "Assets/Resources/GameSettings.asset");
            }

            // Debug.Log($"pre:{settings.gamemode != null}");
            // settings.gamemode = new GamemodeBase<>();


            //Debug.Log($"preLUL:{settings.a}");
            //settings.a = "ree";
            //Debug.Log($"postLUL:{settings}");
            //Debug.Log($"post:{settings.gamemode != null}");
            // EditorUtility.SetDirty(settings);

            //AssetDatabase.SaveAssets();

            editorInstance.Show();
        }
示例#7
0
文件: Input.cs 项目: mikecrews/FFWD
        internal static void Initialize()
        {
            _touches = new Touch[ApplicationSettings.DefaultCapacities.Touches];
#if WINDOWS_PHONE
            TouchPanel.EnabledGestures = GestureType.None;
#endif
#if XBOX
            SignedInGamer.SignedIn += new EventHandler <SignedInEventArgs>((obj, eventArgs) =>
            {
                SignedInGamer gamer = eventArgs.Gamer;
                _gameDefaults       = gamer.GameDefaults;
                if (_gameDefaults.MoveWithRightThumbStick)
                {
                    _moveWithRightThumbStick = true;
                }
            });
#endif
        }
示例#8
0
    private void Start()
    {
        globalData       = FindObjectOfType <GlobalData>().GetComponent <GlobalData>();
        gameDefaults     = globalData.GameDefaults;
        gamePreprocessor = FindObjectOfType <GamePreprocessor>().GetComponent <GamePreprocessor>();
        gameSetupData    = gamePreprocessor.GameSetupData;
        audioManager     = globalData.AudioManager;

        activatedColor = gameDefaults.DefaultColors[Enum_Colors.GREEN_LIGHT];

        soundButtonImage           = GameObject.Find("Mute_Image").GetComponent <Image>();
        soundButtonImageBackground = GameObject.Find("Mute_Image_Background").GetComponent <Image>();

        GameObject.Find("Mute_Image_Background").GetComponent <Image>().color
            = gameDefaults.DefaultColors[Enum_Colors.GREEN_LIGHT];

        // Sets all 'activated state' button's/toggle's image colors.
        SetGameObjectColors();

        UpdateSetupData();
    }
示例#9
0
    /// <summary>
    /// Uses Physics2D.CircleCast to check if there is an obstruction in radius betwen my_pos and target
    /// </summary>
    /// <param name="my_pos">My position in the world</param>
    /// <param name="radius">Thickness of the collision check</param>
    /// <param name="target">End position</param>
    /// <param name="detailed">Make checks more strict</param>
    /// <param name="distance">Distance to target</param>
    /// <returns>Returns true if there is an obstruction. Otherwise returns false.</returns>
    public static bool getCircleSight(Vector2 my_pos, float radius, Vector2 target, bool detailed = true, float distance = 0)
    {
        if (distance == 0)
        {
            distance = (my_pos - target).magnitude;
        }
        distance = Mathf.Abs(distance);
        if (detailed)
        {
            radius   += 0.1f;
            distance -= radius;
            if (distance < 0)
            {
                distance = 0;
                radius  /= 2;
            }
        }

        var targetDir = (target - my_pos).normalized;

        return(Physics2D.CircleCast(my_pos, radius, targetDir, distance, GameDefaults.layerWall()));
    }
示例#10
0
    // Update is called once per frame
    public void Update()
    {
        if (gameObject.CompareTag(GameDefaults.Player()))
        {
            if (listAllPowerups().Count > 0)
            {
                checkPowerups();
                Debug.LogWarning("Pups:" + listAllPowerups().ToString());
            }
            if (controller == null)
            {
                getController("player", new Vector2(0, 0), 0);
            }
        }
        if (controller == null)
        {
            return;
        }

        /*if (Input.GetMouseButtonDown(0) && gameObject.CompareTag(GameDefaults.Enemy()))
         * {
         *  controller.damage(2);
         *  Debug.LogWarning("Napravio 2 dmga objektu:" + parent.GetInstanceID().ToString());
         * }*/
        controller.Update();
        //DEBUG REMOVE AFTER TESTIIIING
        if (stats.ContainsKey("gold") && CompareTag(GameDefaults.Player()))
        {
            Debug.Log("Gold:" + stats["gold"].getCompoundValue());
        }
        Vector2 movement = controller.getMovement();

        rb2d.velocity = movement;
        if (stats.ContainsKey("health") && stats["health"].getCompoundValue() <= 0.0f)
        {
            controller.death();
        }
    }
示例#11
0
 /// <summary>
 /// Uses Physics2D.Linecast to check if the line between my_pos and target is clear of obstructions on the wall layer
 /// </summary>
 /// <param name="my_pos">My position in the world</param>
 /// <param name="target">End position in the world</param>
 /// <returns>Returns true if there is an obstruction. Otherwise returns false.</returns>
 public static bool getLineSight(Vector2 my_pos, Vector2 target)
 {
     return(Physics2D.Linecast(my_pos, target, GameDefaults.layerWall()));
 }
示例#12
0
文件: RangedAI.cs 项目: nmotocic/PPiJ
    // Update is called once per frame
    void Update()
    {
        alarm.Update();
        //Init
        var     my_pos = transform.position;
        Vector3 target;
        //Pick target
        var targetObject = GameObject.FindGameObjectWithTag(targetObjectTag);

        if (targetObject == null) //Mouse
        {
            target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        }
        else //Player
        {
            target = targetObject.transform.position;
        }
        //Update animation
        updateAnimation(Mathf.Sign(my_pos.x - target.x));
        target.z = 0;

        if (AiDefaults.getCircleSight(my_pos, projectileObject.GetComponent <CircleCollider2D>().radius, target, true) && state == 0)
        {   //Target obstructed
            setDestination(target, agent);
            rbody2d.velocity = new Vector2(0, 0);
        }
        else
        {                   //State machine
            //Pick state
            if (state != 0) // Stop moving if winding up an attack
            {
                setDestination(my_pos, agent);
            }
            else //Move
            {
                setDestination(target, agent);
                rbody2d.velocity = new Vector2(0, 0);
            }
            //Hurt
            if (state == GameDefaults.hitState())
            {
                if (alarm.isActive())
                {
                    state = 0;
                }
                danger = false;
            }
            //Death
            else if (state == GameDefaults.deatState())
            {
                //Drop stuff, get removed
                danger = false;
                if (alarm.getMax() != GameDefaults.corpseTimeout())
                {
                    alarm.setMax(GameDefaults.corpseTimeout());
                }
                if (alarm.isActive())
                {
                    GameObject.Destroy(gameObject);
                }
            }

            //--------------------------Attacking
            if (state != GameDefaults.deatState())
            {
                if (Vector2.Distance(my_pos, target) <= attackTriggerRange && state == 0)
                { //Prep attack
                    setDestination(my_pos, agent);
                    state     = 1;
                    targetDir = -(my_pos - target);
                    targetDir.Normalize();
                    startPos = my_pos;
                    //Alarm
                    alarm.setMax(attackWindup);
                    alarm.reset();
                }
                else if (state == 1 && alarm.isActive()) //Wait for alarm
                {                                        //Attack - shoot
                    eScript.DispenseObject(projectileObject, my_pos, targetDir, attackSpeed);
                    //Alarm
                    state = 2;
                    alarm.setMax(attackDuration);
                    alarm.reset();
                }
                else if ((state == 2 & alarm.isActive()))
                { //Attack over - stop
                    rbody2d.velocity = new Vector2(0, 0);
                    state            = 3;
                    alarm.setMax(attackCooldown);
                    alarm.reset();
                }
                else if ((state == 3 & alarm.isActive()))
                { //Attack over - stop
                    state = 0;
                }
                //--------------------------Attacking
            }
        }
    }
示例#13
0
    void Start()
    {
        // Linking scripts.
        globalData         = FindObjectOfType <GlobalData>().GetComponent <GlobalData>();
        gameDefaults       = globalData.GameDefaults;
        audioManager       = FindObjectOfType <AudioManager>().GetComponent <AudioManager>();
        gamePreprocessor   = FindObjectOfType <GamePreprocessor>().GetComponent <GamePreprocessor>();
        playerScoreElement = FindObjectOfType <PlayerScoreElement>().GetComponent <PlayerScoreElement>();
        menuManager        = FindObjectOfType <MenuManager>().GetComponent <MenuManager>();


        // Initializes GameSetupData object.
        gamePreprocessor.NewQuestionsAndAnswers();
        gameTimeLimit = gamePreprocessor.GameSetupData.GameTimeLimit;


        // Finding gameobjects in game.
        answerButtons             = GameObject.FindGameObjectsWithTag("AnswerButton");
        answerFeedbackCanvasGroup = GameObject.Find("Image_AnswerFeedback").GetComponent <CanvasGroup>();
        answerText            = GameObject.Find("Answer_Text").GetComponent <Text>();
        answerTextCanvasGroup = GameObject.Find("Answer_Text").GetComponent <CanvasGroup>();
        clearAnswerButton     = GameObject.Find("Btn_ClearAnswer");
        questionText          = GameObject.Find("Area_Question_Text").GetComponent <Text>();

        gameFinishScreen         = GameObject.Find("GameFinishScreen");
        gameFinishScreenContent  = GameObject.Find("GameFinishScreenContent");
        gameFinishScreenSubTitle = GameObject.Find("GameFinishScreenSubTitle").GetComponent <Text>();
        gameFinishScreenTitle    = GameObject.Find("GameFinishScreenTitle").GetComponent <Text>();

        timerSliderFillLeft  = GameObject.Find("TimerSliderFillLeft").GetComponent <Image>();
        timerSliderFillRight = GameObject.Find("TimerSliderFillRight").GetComponent <Image>();
        timerSliderLeft      = GameObject.Find("TimerSliderLeft").GetComponent <Slider>();
        timerSliderRight     = GameObject.Find("TimerSliderRight").GetComponent <Slider>();
        timerText            = GameObject.Find("Text_TimeRemaining").GetComponent <Text>();

        // Adds listeners for answer button sounds.
        foreach (GameObject go in GameObject.FindGameObjectsWithTag("AnswerButton"))
        {
            go.GetComponentInChildren <Button>().onClick.AddListener(() => audioManager.Play("Btn_Click"));
        }


        // Disables gameFinishScreen.
        gameFinishScreen.GetComponent <CanvasGroup>().alpha        = 0f;
        gameFinishScreenContent.GetComponent <CanvasGroup>().alpha = 0f;


        // Time-limit.
        timerIsOn = true;
        incrementalSliderValue = gameTimeLimit / 4;

        timerSliderFillLeft.color  = gameDefaults.DefaultColors[Enum_Colors.GREEN];
        timerSliderFillRight.color = gameDefaults.DefaultColors[Enum_Colors.GREEN];

        timerSliderLeft.maxValue  = gameTimeLimit;
        timerSliderRight.maxValue = gameTimeLimit;

        timerSliderLeft.value  = gameTimeLimit;
        timerSliderRight.value = gameTimeLimit;


        // Initial labels update.
        UpdateQuestionText();
    }
示例#14
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        GameObject   other   = collision.gameObject;
        EntityScript otherES = other.GetComponent <EntityScript>();

        //Debug.Log(gameObject + "-->" + other);
        if (gameObject.CompareTag(GameDefaults.Projectile()) && (other.CompareTag(GameDefaults.Obstruction())))
        {
            Destroy(gameObject);
            return;
        }
        if (gameObject.CompareTag(GameDefaults.Projectile()) && other.CompareTag(GameDefaults.Projectile()))
        {
            return;
        }
        if (gameObject.CompareTag(GameDefaults.Powerup()) && !other.CompareTag(GameDefaults.Player()))
        {
            return;
        }
        if (other.CompareTag(GameDefaults.Powerup()))
        {
            return;
        }
        if (other.CompareTag(GameDefaults.Obstruction()))
        {
            return;
        }

        if (otherES != null)
        {
            if (parent != null)
            {
                if (other.gameObject.CompareTag(parent.tag) || otherES.parent != null && otherES.parent.gameObject.CompareTag(gameObject.tag))
                {
                    return;
                }
            }

            foreach (string effect in impactEffects.Keys)
            {
                //Debug.Log(effect);
                if (effect.Equals("damage"))
                {
                    if (gameObject.CompareTag(GameDefaults.Enemy()))
                    {
                        if (!gameObject.GetComponent <AiScriptBase>().isDangerous())
                        {
                            continue;
                        }
                        else
                        {
                            gameObject.GetComponent <AiScriptBase>().setDanger(false);
                        }
                    }
                    if (!otherES.stats.ContainsKey("health"))
                    {
                        continue;
                    }

                    float x = impactEffects["damage"].value;
                    if (otherES.stats.ContainsKey("armor"))
                    {
                        FloatStat FSA = otherES.stats["armor"];
                        if (FSA.getCompoundValue() >= 100)
                        {
                            x = 0;
                        }
                        else
                        {
                            x = Mathf.Max(x - FSA.getCompoundValue(), 1f);
                        }
                    }
                    FloatStat FSH = otherES.stats["health"];
                    otherES.controller.damage((int)x);
                    FSH.ChangeWithFactor("baseValue", 0 - x);
                    FSH = new FloatStat("health", Mathf.RoundToInt(FSH.getCompoundValue()));
                }
                else if (effect.Equals("healthBoost"))
                {
                    if (!otherES.stats.ContainsKey("health"))
                    {
                        continue;
                    }

                    float     x   = impactEffects["health"].value;
                    FloatStat FSH = otherES.stats["health"];

                    FSH.ChangeWithFactor("baseValue", x);
                }
                else
                {
                    FSQI effectData = impactEffects[effect];
                    Debug.Log(otherES.stats.ContainsKey(effect).ToString() + effect);
                    if (!otherES.stats.ContainsKey(effect))
                    {
                        continue;
                    }
                    effectData.ApplyTo(otherES);
                }
            }
        }
        if (gameObject.CompareTag(GameDefaults.Powerup()) && other.CompareTag(GameDefaults.Player()))
        {
            Destroy(gameObject);
            return;
        }
        //Stari kod
        if (true) //Unity ima ugrađene tagove i layere, zasto si stvarao svoje?
        {
            //Projectile collisions
            if (gameObject.CompareTag(GameDefaults.Projectile()))
            {
                //Obstruction
                if (other.CompareTag(GameDefaults.Obstruction()))
                {
                    Destroy(gameObject);
                    return;
                }
                if (parent != null && !parent.CompareTag(other.gameObject.tag))
                {
                    controller.OnTriggerEnter2D(collision);
                    GameObject.Destroy(gameObject);

                    // Wake up any script that is attached to the enemy + navmesh
                    var otherChaser = other.GetComponent <AiScriptBase>();
                    if (otherChaser != null && !otherChaser.enabled)
                    {
                        otherChaser.enabled = true;
                        other.GetComponent <NavMeshAgent>().enabled = true;
                    }
                }
            }
            //Enemy coll
            else if (gameObject.CompareTag(GameDefaults.Enemy()))
            {
                //Obstruction
                if (other.CompareTag(GameDefaults.Obstruction()))
                {
                    //Zid
                }
                //Enemy
                else if (other.CompareTag(GameDefaults.Enemy()))
                {
                    //var es = other.gameObject.GetComponent<EntityScript>();
                }
                //Player
                else if (other.gameObject.CompareTag(GameDefaults.Player()))
                {
                    if (controller != null && collision != null)
                    {
                        controller.OnTriggerEnter2D(collision);
                    }
                }
            }
            else if (gameObject.CompareTag(GameDefaults.Player()))
            {
                if (other.gameObject.CompareTag(GameDefaults.LevelExit()))
                {
                    if (controller != null && collision != null)
                    {
                        controller.OnTriggerEnter2D(collision);
                    }
                }
            }
        }
    }
示例#15
0
    // Update is called once per frame
    void Update()
    {
        if (permaBuff)
        {
            buff = true;
        }
        alarm.Update();
        aiTimer.Update();
        //Init
        var     my_pos = transform.position;
        Vector3 target;
        //Pick target
        var targetObject = GameObject.FindGameObjectWithTag(targetObjectTag);

        if (targetObject == null) //Mouse
        {
            target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        }
        else //Player
        {
            target = targetObject.transform.position;
        }
        //Update animation
        updateAnimation(Mathf.Sign(my_pos.x - target.x));
        target.z = 0;
        //Reset idle
        if (state == 5 && alarm.isActive())
        {
            state = 0;
        }
        //Reset attack alarm
        if (attackType != 0 && state == 0)
        {
            attackType = 0;
            aiTimer.reset();
        }

        //LoS
        if (state == 0 && AiDefaults.getLineSight(my_pos, target))
        {   //Target obstructed
            setDestination(target, agent);
            rbody2d.velocity = new Vector2(0, 0);
        }
        else
        {                   //State machine
            //Pick state
            if (state == 0) // Move
            {
                setDestination(target, agent);
                rbody2d.velocity = new Vector2(0, 0);
            }
            else //Move
            {
            }

            //Hurt
            if (state == GameDefaults.hitState())
            {
                if (alarm.isActive())
                {
                    state = 0;
                }
                danger = false;
            }
            //Death
            else if (state == GameDefaults.deatState())
            {
                //Drop stuff, get removed
                danger = false;
                GameObject.Destroy(myBuff);
                myBuff = null;
            }

            //--------------------------Attacking
            //Pick attack
            if (Vector2.Distance(my_pos, target) <= autoTriggerAtackDist && state == 0 && attackType == 0) //Attack player immediately
            {
                pickAttack();
                while (attackType == -1 || attackType == 4)
                {
                    pickAttack();
                }
                Debug.Log("Picked attack:" + attackType.ToString());
            }
            else if (aiTimer.isActive() && attackType == 0 && state == 0)
            {
                pickAttack();
                while (buff && attackType == 4)
                {
                    pickAttack();
                }
                Debug.Log("Picked attack:" + attackType.ToString());
            }
            //Attacks
            if (attackType > 0)
            {
                //attackType = 4;
                //Dash
                if (attackType == 1)
                {
                    //Windup
                    if (state == 0)
                    {
                        state = 1;
                        alarm.setMax(dashWindup);
                        alarm.reset();
                        //Stop moving
                        setDestination(my_pos, agent);
                    }
                    //Start
                    else if (state == 1 && alarm.isActive())
                    {
                        state  = 2;
                        danger = true;
                        //Set agent speeds
                        if (buff)
                        {
                            agent.speed        = dashSpeed * 1.5f;
                            agent.angularSpeed = dashAngular * 4f;
                            agent.acceleration = dashAccel * 4f;
                            setDestination(target, agent);
                            buff = false;
                            if (myBuff != null)
                            {
                                myBuff.GetComponent <AI_Effect>().deActivate();
                            }
                            alarm.setMax(dashDuration / 2);
                            alarm.reset();
                        }
                        else
                        {
                            agent.speed        = dashSpeed;
                            agent.angularSpeed = dashAngular;
                            agent.acceleration = dashAccel;
                            setDestination(target, agent);
                            alarm.setMax(dashDuration);
                            alarm.reset();
                        }
                    }
                    //End
                    else if ((state == 2) && (alarm.isActive() || !danger))
                    {
                        setState(3); //Stab state
                        alarm.setMax(dashCooldown / 2);
                        alarm.reset();
                        danger = false;
                    }
                    //Cooldown
                    else if ((state == 3) && (alarm.isActive()))
                    {
                        state = 5; //IdleState
                        alarm.reset();
                    }
                }
                //Slash
                else if (attackType == 2)
                {
                    targetDir = -(my_pos - target);
                    targetDir.Normalize();
                    if (state == 0)
                    {
                        state = 1;
                        alarm.setMax(slashWindup);
                        alarm.reset();
                        //Stop moving
                        setDestination(my_pos, agent);

                        if (buff)
                        {
                            attackCombo = 2;
                            buff        = false;
                            if (myBuff != null)
                            {
                                myBuff.GetComponent <AI_Effect>().deActivate();
                            }
                        }
                        else
                        {
                            attackCombo = 0;
                        }
                    }
                    //Start
                    else if (state == 1 && alarm.isActive())
                    {
                        state = 2;
                        alarm.setMax(slashDuration);
                        alarm.reset();
                        eScript.DispenseObject(slashProjectile, my_pos, targetDir, slashProjectileSpeed);
                    }
                    //Swing
                    else if ((state == 2) && (alarm.isActive()))
                    {
                        if (attackCombo > 0)
                        { //Moar swings
                            attackCombo--;
                            state = 1;
                            alarm.setMax(slashWindup / 6);
                            alarm.reset();
                        }
                        else
                        { //Cooldown
                            state = 5;
                            alarm.setMax(slashCooldown);
                            alarm.reset();
                        }
                    }
                }
                //Spin
                else if (attackType == 3)
                {
                    if (state == 0)
                    {
                        state = 1;
                        alarm.setMax(spinWindup);
                        alarm.reset();
                        //Stop moving
                        setDestination(my_pos, agent);
                    }
                    //Start
                    else if (state == 1 && alarm.isActive())
                    {
                        state = 2;
                        alarm.setMax(spinInterval);
                        alarm.reset();

                        if (buff)
                        {
                            attackCombo = spinProjectiles;
                            buff        = false;
                            if (myBuff != null)
                            {
                                myBuff.GetComponent <AI_Effect>().deActivate();
                            }
                            attackCount = 4;
                        }
                        else
                        {
                            attackCombo = spinProjectiles;
                            attackCount = 1;
                        }
                    }
                    //Spin and launch
                    else if ((state == 2) && (alarm.isActive()))
                    {
                        if (attackCombo > 0)
                        { //Keep launching
                            state = 2;
                            alarm.setMax(spinInterval);
                            alarm.reset();
                            attackCombo--;
                            for (int i = 0; i < attackCount; i++)
                            {
                                Vector2 randVector = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f));
                                randVector.Normalize();
                                eScript.DispenseObject(slashProjectile, my_pos, randVector, slashProjectileSpeed);
                            }
                        }
                        else
                        { //Cooldown
                            state = 3;
                            alarm.setMax(spinCooldown / 3);
                            alarm.reset();
                        }
                    }
                    else if (state == 3 && alarm.isActive())
                    {
                        state = 5;
                        alarm.setMax(2 * spinCooldown / 3);
                        alarm.reset();
                    }
                }
                //Buff
                else if (attackType == 4)
                {
                    if (state == 0)
                    {
                        state = 1;
                        alarm.setMax(slamWindup);
                        alarm.reset();
                        //Stop moving
                        setDestination(my_pos, agent);
                    }
                    //Slam
                    else if (state == 1 && alarm.isActive())
                    {
                        state = 2;
                        alarm.setMax(slamDuration);
                        alarm.reset();
                        //Launch 4 projectiles
                        eScript.DispenseObject(slashProjectile, my_pos, Vector2.down, slashProjectileSpeed);
                        eScript.DispenseObject(slashProjectile, my_pos, Vector2.up, slashProjectileSpeed);
                        eScript.DispenseObject(slashProjectile, my_pos, Vector2.left, slashProjectileSpeed);
                        eScript.DispenseObject(slashProjectile, my_pos, Vector2.right, slashProjectileSpeed);
                        buff = true;
                        if (myBuff != null)
                        {
                            myBuff.GetComponent <AI_Effect>().activate();
                        }
                    }
                    //Slam done
                    else if ((state == 2) && (alarm.isActive()))
                    {
                        state = 5;
                        alarm.setMax(slamCooldown);
                        alarm.reset();
                    }
                }
            }
        }
    }