Пример #1
0
 void initializeEventCallbacks()
 {
     StartedCastingEvent.RegisterListener(castingStarted);
     StoppedCastingEvent.RegisterListener(castingStopped);
     SpellSelectedEvent.RegisterListener(SpellSelected);
     SpellCastEvent.RegisterListener(SpellCast);
     SpellUnSelectedEvent.RegisterListener(SpellUnselected);
     CastingProjectionDestroyedEvent.RegisterListener(CastingProjectionDestroyed);
     CastingProjectionCreatedEvent.RegisterListener(CastingProjectionCreated);
     CastingLocationChangedEvent.RegisterListener(CastingLocationChanged);
 }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        Horizontal = Input.GetAxisRaw("Horizontal");
        Vertical   = Input.GetAxisRaw("Vertical");

        if (casting && Input.GetKeyUp("space"))
        {
            StopCasting();
        }

        if (Input.GetKeyDown("space"))
        {
            StartCasting();
        }

        if (IsAttacking)
        {
            Debug.Log("update loop stooped cause attacting");
            return;
        }

        if (Input.GetKeyDown(KeyCode.Period))
        {
            IsAttacking = true;
            Animate.ChangeAnimationState("Attacking", animator, currentDirection);

            PrepareAttackHitboxes(currentDirection);

            Horizontal = 0;
            Vertical   = 0;
        }



        //TODO: dont want to be doing this, but i must for now, means when holding space (casting) you cant move
        else if (Input.GetKey(KeyCode.Space) == false)
        {
            if (Vertical != 0 && Horizontal == 0)
            {
                if (Vertical > 0)
                {
                    if (currentDirection != Direction.NORTH || IsIdle)
                    {
                        currentDirection = Direction.NORTH;
                        Animate.ChangeAnimationState("Walk", animator, currentDirection);
                    }
                }
                else
                {
                    if (currentDirection != Direction.SOUTH || IsIdle)
                    {
                        currentDirection = Direction.SOUTH;
                        Animate.ChangeAnimationState("Walk", animator, currentDirection);
                    }
                }

                IsIdle = false;
            }
            else if (Horizontal != 0)
            {
                if (Horizontal > 0)
                {
                    if (currentDirection != Direction.EAST || IsIdle)
                    {
                        currentDirection = Direction.EAST;
                        Animate.ChangeAnimationState("Walk", animator, currentDirection);
                    }
                    //Flip();
                }
                else if (Horizontal < 0)
                {
                    if (currentDirection != Direction.WEST || IsIdle)
                    {
                        currentDirection = Direction.WEST;
                        Animate.ChangeAnimationState("Walk", animator, currentDirection);
                    }

                    //Flip();
                }

                IsIdle = false;
            }
            else
            {
                if (IsIdle == false)
                {
                    Animate.ChangeAnimationState("Idle", animator, currentDirection);
                    //currentDirection = Direction.IDLE;
                    IsIdle = true;
                }
            }

            //Vector3 tempVect = new Vector3(Horizontal, Vertical, 0);
            //tempVect = tempVect.normalized * speed * Time.deltaTime;

            //this.transform.position += tempVect;
        }
        else if (casting)
        {
            // character is currently casting
            float h = Input.GetAxis("Horizontal");
            float v = Input.GetAxis("Vertical");

            if (h != 0 || v != 0)
            {
                if (castingLocationChanged == false)
                {
                    //We are wanting to move the casting projection, so lets see if we need to instantiate it
                    if (CastingCircleProjection == null)
                    {
                        CastingCircleProjection = Instantiate(CastingCircleProjectionPrefab, this.transform.position, Quaternion.identity);
                        CastingProjectionCreatedEvent e = new CastingProjectionCreatedEvent();
                        e.castingProjection = CastingCircleProjection;
                        e.FireEvent();
                    }

                    CastingCircleProjection.transform.position += new Vector3(h, v).normalized *speed *Time.deltaTime;
                }
            }
        }

        if (Input.GetKeyDown("f"))
        {
            if (CastingCircleProjection != null)
            {
                CastingLocationChangedEvent e = new CastingLocationChangedEvent();
                e.go = CastingCircleProjection;
                e.FireEvent();
                castingLocationChanged = true;
                Destroy(CastingCircleProjection);
                CastingCircleProjection = null;
            }
        }

        if (Input.GetKeyDown("j"))
        {
            SpellCastCall e = new SpellCastCall();
            e.FireEvent();
            //CrawlController.instance.ConsumeCrawl(transform.position, consumeAmount, consumePixelsPerFrame);
        }
        if (Input.GetKeyDown("p"))
        {
            Vector2 bottom = transform.position;
            crawlController.CreateCrawl(bottom);
        }

        if (Input.GetKeyDown("r"))
        {
            Vector2 bottom = transform.position;
            crawlController.AddFire(bottom);
            //animator.SetBool("Casting", true);
        }

        if (Input.GetKeyDown("q"))
        {
            Vector2 bottom = transform.position;

            WaterControllerScript.instance.AddWater(bottom, 100);
        }

        //if (Input.GetKeyDown("e"))
        //{

        //    if(runningCrawl == null)
        //    {
        //        runningCrawl = crawlController.CreateCrawl(transform.position);
        //        runningStartPosition = transform.position;
        //        runningStartTime = Time.time;
        //    }

        //} else if(runningCrawl != null)
        //{

        //    if (Time.time - runningStartTime >= 3)
        //    {
        //        runningCrawl = null;

        //    }
        //    else
        //    {
        //        int startingPixel = crawlController.GetWidth()/2;

        //        int startX = startingPixel + (int)transform.position.x;
        //        int startY = startingPixel + (int)transform.position.y;


        //        runningCrawl.GrowByPosition(new Vector2(startX, startY));
        //    }

        //}


        //void Flip()
        //{
        //    facingRight = !facingRight;
        //    Vector3 theScale = transform.localScale;
        //    theScale.x *= -1;
        //    transform.localScale = theScale;
        //}
    }
 void castingProjectionCreated(CastingProjectionCreatedEvent e)
 {
     currentObject = e.castingProjection;
 }
    // All callback functions the camera recieves
    #region Callback functions

    void initializeCallbackFunctions()
    {
        CastingProjectionDestroyedEvent.RegisterListener(castingProjectionDestroyed);
        CastingProjectionCreatedEvent.RegisterListener(castingProjectionCreated);
        CastingLocationChangedEvent.RegisterListener(castingLocationChanged);
    }
Пример #5
0
 void CastingProjectionCreated(CastingProjectionCreatedEvent e)
 {
     castingProjectionActive = true;
 }