void Start()
    {
        throwArmAnim = throwArm.GetComponent <BasicAnimator>();

        armSprite      = arm.GetComponent <SpriteRenderer>();
        throwArmSprite = throwArm.GetComponent <SpriteRenderer>();

        reloaded    = true;
        fire        = false;
        setCooldown = cooldown;

        if (playerController.player == Controller.Player1)
        {
            controllerCode = controllerOne;
            fireBomb       = shockwaveBomb;
            flipValue      = 1;
        }
        else
        {
            controllerCode = controllerTwo;
            fireBomb       = gravityBomb;
            flipValue      = -1;
        }
        rightXAxis += controllerCode;
        rightYAxis += controllerCode;
    }
Beispiel #2
0
 void Awake()
 {
     rigi             = GetComponent <Rigidbody2D>();
     inventory        = GetComponent <Inventory>();
     basic_animator   = GetComponent <BasicAnimator>();
     movement         = GetComponent <Movement>();
     audio_controller = FindObjectOfType <AudioController>();
 }
Beispiel #3
0
        /// <inheritdoc />
        protected sealed override void OnInitialize()
        {
            base.OnInitialize();
            int    m      = Random.Next(5);
            Sprite sprite = new Sprite(AssetManager.Get <SpriteTexture>(this, "floor"), Color.White)
            {
                LayerDepth = 0.1f,
            };

            AddComponent(sprite);

            Vector2         startPos = Transform.Position;
            AnimatedVector2 f        = new AnimatedVector2();
            Curve           c        = new Curve();

            c.Keys.Add(new CurveKey(0, 0));
            c.Keys.Add(new CurveKey(1, 200));
            c.Keys.Add(new CurveKey(2, 100));
            c.Keys.Add(new CurveKey(2.5f, 300));
            f.SetCurve(c, c);
            f.Attach(new Ref <Vector2>(i => Transform.Position = i + startPos));
            Animation aC = new Animation(f)
            {
                WrapMode = WrapMode.PingPong
            };

            AnimatedVector2 f2 = new AnimatedVector2();
            Curve           c2 = new Curve();

            c2.Keys.Add(new CurveKey(0, 100));
            c2.Keys.Add(new CurveKey(1, 400));
            c2.Keys.Add(new CurveKey(2, 150));
            c2.Keys.Add(new CurveKey(2.5f, 250));
            f2.SetCurve(c2, c2);
            f2.Attach(new Ref <Vector2>(i => Transform.Position = i + startPos));

            AnimatedColor col = new AnimatedColor();

            col.SetLerp(Color.White, new Color((byte)Random.Next(255), (byte)Random.Next(255), (byte)Random.Next(255), (byte)1.0f), 2.5f);
            col.Attach(new Ref <Color>(color => {
                List <Sprite> sprites = GetAllComponents <Sprite>();
                for (int i = 0; i < sprites.Count; i++)
                {
                    sprites[i].Color = color;
                }
            }));

            Animation aC2 = new Animation(f2);

            aC2.Add(col);
            aC2.WrapMode = WrapMode.PingPong;

            anim = new BasicAnimator();
            anim.AddAnimation("Anim", aC);
            anim.AddAnimation("Anim2", aC2);
            AddComponent(anim);
            anim.Play("Anim2");
        }
Beispiel #4
0
    void Awake()
    {
        myBox = GetComponent <BoxCollider2D>();

        capsuleRadiusX = myBox.size.x * transform.localScale.x / 2;
        capsuleRadiusY = myBox.size.y * transform.localScale.y / 2;

        capsuleOffSetX = myBox.offset.x;
        capsuleOffSetY = myBox.offset.y;

        savedColliderSize   = myBox.size;
        savedColliderOffSet = myBox.offset;

        savedSpeed = speed;

        // FIX JUMP
        //
        // Arm, ThrowArm, Hide sprite renderer ocn "Arm" when attacking, show "ThrowArm" wait until throw is done, then hide throw arm
        // and show normal "arm" again.
        //
        bodyAnim = GetComponent <BasicAnimator>();
        GameObject arm = this.transform.Find("Arm").gameObject;

        armAnim = arm.GetComponent <BasicAnimator>();
        //
        //

        rigidbody2D = GetComponent <Rigidbody2D>();


        if (player == Controller.Player1)
        {
            controllerCode = controllerOne;
            flipped        = false;
        }
        else
        {
            controllerCode = controllerTwo;
            flipped        = true;
        }

        horAx      += controllerCode;
        verAx      += controllerCode;
        jumpInput  += controllerCode;
        crawlInput += controllerCode;

        if (flipped)
        {
            Flip();
        }

        isActive = true;
        inAir    = true;

        movementAudio = GetComponent <MovementAudio>();
    }
    // Use this for initialization
    void Start()
    {
        if (GetComponent <BasicAnimator>())
        {
            bAnim = GetComponent <BasicAnimator>();
        }

        if (GetComponent <AIMovement>())
        {
            AImove = GetComponent <AIMovement>();
        }
    }
    //
    protected virtual void Awake()
    {
        if (GetComponent <BasicAnimator>())
        {
            bAnim = GetComponent <BasicAnimator>();
        }

        currentState = startState;

        if (GetComponent <Rigidbody2D>())
        {
            rigidbody2D = GetComponent <Rigidbody2D>();
        }

        for (int i = 0; i < checkPoints.Count; i++)
        {
            checkPointPos.Add(checkPoints[i].transform.position);
            checkPointCheck.Add(false);
        }

        //Maxslope
        maxSlope = Mathf.Sin((maxSlope * Mathf.PI) / 180);

        directionMultiplier = new Vector2(1, 0);

        // Raydistance
        rayDistanceHypot = Mathf.Pow((GetComponent <BoxCollider2D>().size.y *GetComponent <Transform>().localScale.y), 2) + // X^2
                           Mathf.Pow((GetComponent <BoxCollider2D>().size.x *GetComponent <Transform>().localScale.x), 2);  // Y^2

        rayDistanceHypot  = Mathf.Sqrt(rayDistanceHypot);
        rayDistanceHypot += 0.0f; // offSet.

        // rayDistanceHypot = 0.7f;

        // SlopeRay
        rayOffSetX = GetComponent <BoxCollider2D>().size.x *transform.localScale.x / 2;
        rayOffSetY = GetComponent <BoxCollider2D>().size.y *transform.localScale.y / 2;
        boxOffSetY = GetComponent <BoxCollider2D>().offset.y;
        boxOffSetX = GetComponent <BoxCollider2D>().offset.x * -1;

        slopeRayOffset = rayOffSetY;

        //Xray
        rayDistanceX = Mathf.Abs((GetComponent <BoxCollider2D>().size.x *transform.localScale.x / 2));

        if (flipped)
        {
            Flip();
        }
    }
Beispiel #7
0
    /*
     * [SerializeField]
     * private AudioClip attackSound;
     * [SerializeField]
     * private AudioClip idleSound;
     * [SerializeField]
     * private AudioClip flyingSound;
     * private AudioSource audioSource;
     */

    private void Start()
    {
        rb = GetComponent <Rigidbody2D>();
        sr = GetComponent <SpriteRenderer>();

        // If the BasicAnimator component is missing, add it. Should not need any configuration
        if (GetComponent <BasicAnimator>() == null)
        {
            gameObject.AddComponent <BasicAnimator>();
        }

        bodyAnim  = GetComponent <BasicAnimator>();
        targetPos = buzzerTarget.transform.position;

        playerTarget = GameManager.instance.playerBot;
    }
Beispiel #8
0
    private void Start()
    {
        basicAnimator = GetComponent <BasicAnimator>();
        try
        {
            mobAnimator = GetComponent <MobAnimator>();
        }
        catch (Exception ex)
        {
            Debug.Log(ex);
            Debug.Log("Couldn't find mob animator or boss animator");
            throw;
        }
        curHealth = maxHealth;

        OnMinionDeath += DisableComponents;
        OnMinionDeath += SpawnRune;
        healthScale    = minionHealth.transform.localScale;
    }
Beispiel #9
0
    void Start()
    {
        playerController = GetComponent <PlayerController>();

        if (playerController.player == Controller.Player1)
        {
            pushAndPullBox += c1;
        }
        else
        {
            pushAndPullBox += c2;
        }
        distance = 1f;

        arm  = playerController.armAnim;
        body = playerController.bodyAnim;

        emitter = GetComponent <FMODEmitter>();
    }
Beispiel #10
0
        /// <summary>
        /// Configures the UIAnimation component by adding some generic animations: idle, highlight, click.
        /// </summary>
        /// <param name="idle">Idle animation state.</param>
        /// <param name="highlighted">Highlight animation state.</param>
        /// <param name="clicked">Click animation state.</param>
        /// <param name="toggled">Toggled animation state.</param>
        public void Configure(Animation idle, Animation highlighted, Animation clicked, Animation toggled)
        {
            Idle        = idle;
            Highlighted = highlighted;
            Clicked     = clicked;

            AnimatorComponent = new BasicAnimator();
            AnimatorComponent.AddAnimation("idle", Idle);
            AnimatorComponent.AddAnimation("highlight", Highlighted);
            AnimatorComponent.AddAnimation("click", Clicked);
            if (toggled != null)
            {
                Toggled = toggled;
                AnimatorComponent.AddAnimation("toggle", Toggled);
            }
            Owner.AddComponent(AnimatorComponent);

            AnimatorComponent.Play("idle");
            Configured = true;
        }