Exemple #1
0
    void HUDActualization()
    {
        Lifebar LB = GetComponent <Lifebar>();

        //Debug.Log(stack);
        LB.addPowerUp(stack);
    }
Exemple #2
0
 void Start()
 {
     instance = this;
     slider = this.GetComponent<Slider>();
     slider.value = 100;
     maxLife = slider.value;
     Debug.Log("Currentlife " + slider.value);
 }
Exemple #3
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
 }
Exemple #4
0
    void Awake()
    {
        scoreText = playerUI.GetComponentInChildren <Text>();
        lifebar   = playerUI.GetComponentInChildren <Lifebar>();

        Vector2[] meshShape =
        {
            new Vector2(0,   3),
            new Vector2(2,  -2),
            new Vector2(0,  -1),
            new Vector2(-2, -2)
        };

        // Use the triangulator to get indices for creating mesh collider
        Triangulator tr = new Triangulator(meshShape);

        int[] indices = tr.Triangulate();

        // Create the Vector3 vertices
        Vector3[] vertices = new Vector3[meshShape.Length];
        for (int i = 0; i < vertices.Length; i++)
        {
            vertices[i] = new Vector3(meshShape[i].x, 0, meshShape[i].y);
        }

        // Create the mesh
        Mesh msh = new Mesh();

        msh.vertices  = vertices;
        msh.triangles = indices;
        msh.RecalculateNormals();
        msh.RecalculateBounds();

        //Initialise collider and renderer.
        MeshFilter filter = GetComponent <MeshFilter>();

        filter.mesh = msh;
        MeshCollider collider = GetComponent <MeshCollider>();

        collider.sharedMesh = msh;
        mBody = GetComponent <Rigidbody>();

        //Set lives count
        currentLives = MaxLives;
        lifebar.SetLife(currentLives);
        thrustIcon = transform.GetChild(1).gameObject;
        IsDead     = false;
    }
    private void Start()
    {
        lifebar = GetComponentInChildren <Lifebar>();
        lifebar.SetLife(1);
        startHealth = health;
        target      = GameObject.FindWithTag("Player");
        var animator = GetComponentInChildren <Animator>();

        animator.SetBool("Walk", true);

        NavMeshHit closestHit;

        if (NavMesh.SamplePosition(transform.position, out closestHit, 500, 1))
        {
            transform.position = closestHit.position;
            agent = GetComponent <NavMeshAgent>();
        }
    }
Exemple #6
0
    public void Hit(Vector3 dir)
    {
        if (lastTimeHit > INV_TIME)
        {
            violentTimer = 0;

            lastTimeHit = 0;

            rigidbody.velocity += dir.normalized * HIT_RESPONSE_INTENSITY + -Physics.gravity.normalized * HIT_RESPONSE_INTENSITY;

            ChangeState(PlayerState.Hurt);
            Lifebar lb = GetComponent <Lifebar>();
            if (lb.enabled)
            {
                lb.gotHit();
            }
        }
    }
Exemple #7
0
    void Start()
    {
        player  = FindObjectOfType <Player>();
        machine = FindObjectOfType <ComputerAI>();

        fight = GameObject.Find("Fight").GetComponent <RectTransform>();

        leftBar  = GameObject.Find("LifeBar_left").GetComponent <Lifebar>();
        rightBar = GameObject.Find("LifeBar_right").GetComponent <Lifebar>();

        koText = GameObject.Find("KO").GetComponent <RectTransform>();
        koText.anchoredPosition = Vector2.up * 10000;

        win = GameObject.Find("KO/win").GetComponent <Text>();

        ball = FindObjectOfType <Ball>();

        ball.OutLeft  = AddDamageToLeft;
        ball.OutRight = AddDamageToRight;

        StartCoroutine(Starting());
        ball.FreezeBall();
    }
Exemple #8
0
        protected override void LoadScreenContent(ContentManager content)
        {
            atkBlock   = content.Load <Texture2D>(@"Blocks/attack");
            shldBlock  = content.Load <Texture2D>(@"Blocks/shield");
            redBlock   = content.Load <Texture2D>(@"Blocks/red");
            greenBlock = content.Load <Texture2D>(@"Blocks/green");
            blueBlock  = content.Load <Texture2D>(@"Blocks/blue");
            multiBlock = content.Load <Texture2D>(@"Blocks/multi");
            well       = content.Load <Texture2D>(@"Images/wellbackground");

            debugFont = content.Load <SpriteFont>(@"Fonts/debugFont");

            //lifebar
            emptyBarTexture = content.Load <Texture2D>(@"Images/lifebar_empty");
            lifeBarTexture  = content.Load <Texture2D>(@"Images/lifebar_solid");
            redLifeTexture  = content.Load <Texture2D>(@"Images/lifebar_red");

            screenArea = new Rectangle(0, 0, Screen.ScreenWidth, Screen.ScreenHeight);
            input.AddTouchGestureInput(screenTapped, GestureType.Tap, screenArea);
            input.AddTouchGestureInput(screenHold, GestureType.Hold, screenArea);

            level     = new Level(atkBlock, shldBlock, redBlock, greenBlock, blueBlock, multiBlock, well, 3);
            playerBar = new Lifebar(emptyBarTexture, lifeBarTexture, redLifeTexture, 100, 20);
        }
Exemple #9
0
 // Use this for initialization
 void Awake()
 {
     canvas    = GetComponent <Canvas> ();
     scoreText = canvas.transform.Find("Score").GetComponent <Text> ();
     lifebar   = GetComponentInChildren <Lifebar> ();
 }