Пример #1
0
 public void PreInitialize(BattleMgr bMgr, UIMgr uMgr, Entity nActor, AttackTracker aTracker)
 {
     uiMgr         = uMgr;
     battleMgr     = bMgr;
     nowActor      = nActor;
     attackTracker = aTracker;
 }
Пример #2
0
            public void BuildAttack(AllServices services)
            {
                fgService   = services.GetService <IFightingGameService>();
                projectServ = services.GetService <IProjectileService>();
                audioServ   = services.GetService <IAudioService>();

                fgChar = services.GetService <IBuildService>().GetBuildingFGChar();

                AttackBuilder attackBuilder = new AttackBuilder(services);

                builderCallback(attackBuilder);

                attackBuilder.BuildAttack();

                name           = attackBuilder.name;
                orientation    = attackBuilder.orientation;
                groundRelation = attackBuilder.groundRelation;
                input          = attackBuilder.input;
                priority       = 1;
                animStateName  = attackBuilder.animStateName;

                frames   = attackBuilder.GetFrames();
                hitBoxes = attackBuilder.GetHitBoxes();

                tracker = new AttackTracker(frames.Count);
            }
Пример #3
0
 public virtual void Init()
 {
     tracker = GameObject.FindObjectOfType <AttackTracker>() as AttackTracker;
     EventMgr.Instance.AddListener <TurnEnds>(UpdateOrder);
     EventMgr.Instance.AddListener <MonsterDies>(Die);
     attackReady = false;
     chargeReady = true;
     charge      = false;
 }
Пример #4
0
    private void Shoot()
    {
        if (attackTracker != AttackTracker.IDLE)
        {
            return;
        }
        // Get mouse position
        Vector3 mousePos = Input.mousePosition;

        mousePos.z = 0;
        // Convert to world position
        Vector3 worldMouse = mainCamera.ScreenToWorldPoint(mousePos);

        // Create Burst Attack
        GameObject firedShot  = Instantiate(burst);
        int        burstColor = (int)ColorSelector.GetColor();

        firedShot.GetComponent <Explode>().burstProperties = burstTypes[burstColor];
        firedShot.transform.position = transform.position;

        firedShot.tag = ColorSelector.GetColor().ToString();

        // Color changes
        Color color          = new Color();
        Color highlightColor = new Color();

        ColorUtility.TryParseHtmlString(ColorScheme.primaryColors[burstColor], out color);
        ColorUtility.TryParseHtmlString(ColorScheme.highlightColors[burstColor], out highlightColor);
        firedShot.GetComponent <SpriteRenderer>().color = color;
        firedShot.transform.GetComponent <TrailRenderer>().startColor = highlightColor;
        firedShot.transform.GetComponent <TrailRenderer>().endColor   = highlightColor;

        PhysicsMaterial2D physMat = new PhysicsMaterial2D();

        physMat.bounciness = burstTypes[burstColor].bounciness;
        physMat.friction   = burstTypes[burstColor].friction;
        firedShot.GetComponent <Rigidbody2D>().sharedMaterial = physMat;
        firedShot.GetComponent <Rigidbody2D>().drag           = burstTypes[burstColor].drag;

        firedShot.transform.localScale = new Vector2(burstTypes[burstColor].size, burstTypes[burstColor].size);

        // Force Calculations + Launch
        float angle = Mathf.Atan2(worldMouse.y - transform.position.y, worldMouse.x - transform.position.x);

        //float distance = Mathf.Sqrt(Mathf.Pow(worldMouse.x - transform.position.x, 2) + Mathf.Pow(worldMouse.y - transform.position.y, 2));
        firedShot.GetComponent <Rigidbody2D>().AddForce(new Vector2(maxForce * Mathf.Cos(angle) * Mathf.Clamp(Mathf.Abs(worldMouse.x - transform.position.x) / maxDistance, 0, 1), maxForce * Mathf.Sin(angle) * Mathf.Clamp(Mathf.Abs(worldMouse.y - transform.position.y) / maxDistance, 0, 1)));



        // Resets player to Reload atttack state
        attackTracker = AttackTracker.RELOAD;
    }
Пример #5
0
 void FixedUpdate()
 {
     if (StateReciever.GetState() == States.INACTIVE)
     {
         return;
     }
     if (attackTracker == AttackTracker.RELOAD)
     {
         if (reloadTracker > reloadTime)
         {
             reloadTracker = 0;
             attackTracker = AttackTracker.IDLE;
         }
         else
         {
             reloadTracker++;
         }
     }
 }
Пример #6
0
 void Start()
 {
     mainCamera    = Camera.main;
     attackTracker = AttackTracker.IDLE;
 }