Exemple #1
0
    void placePlacement(bool buying)
    {
        RaycastHit hit;
        Vector3    mousePos = Input.mousePosition;

        if (Input.GetMouseButtonDown(1))
        {
            if (Physics.SphereCast(Camera.main.ScreenPointToRay(mousePos), 1, out hit, Mathf.Infinity, placementLayer))
            {
                if (placingObject.GetComponent <WorldInteractive>() != null)
                {
                    placingObject.GetComponent <WorldInteractive>().beingMoved = false;
                }
                OnPlacementInteract?.Invoke(false);
                placingObject.layer = 12;
                if (buying)
                {
                    callForPurchase();
                    Debug.Log("HÄr");
                }

                placingObject = null;
                SetPlacing(false);
                SetMoving(false);
                PointAndClickMovement.setMovementStatus(true);
                MainCanvas.mainCanvas.freezeOverride = false;
                resetPlaneLayers();
            }
        }
    }
Exemple #2
0
    void startPlacement(BuyObject buyObject)
    {
        if (placingObject != null)
        {
            Destroy(placingObject);
            OnPlacementInteract?.Invoke(true, true);
        }
        else
        {
            OnPlacementInteract?.Invoke(true);
        }
        placingObject = Instantiate(buyObject.GetBuyObjectScriptable().prefab);
        placingObject.transform.rotation = Quaternion.Euler(0, 130, 0);
        if (placingObject.GetComponent <BuyObjectBehaviour>() == null)
        {
            placingObject.AddComponent <BuyObjectBehaviour>();
        }
        placingObject.GetComponent <BuyObjectBehaviour>().Initialize(buyObject.BuyValue, buyObject.SatisfactionGain);

        currentBuyObject = buyObject;
        meshBounds       = placingObject.GetComponent <Collider>().bounds;
        ignoredPlanes    = getIgnorableTransforms(placingObject);

        PointAndClickMovement.setMovementStatus(false);
        MainCanvas.mainCanvas.freezeOverride = true;
        SetPlacing(true);

        if (placingObject.GetComponent <WorldInteractive>() != null)
        {
            placingObject.GetComponent <WorldInteractive>().beingMoved = true;
        }
    }
Exemple #3
0
    // Use this for initialization
    void Start()
    {
        if (networkView.isMine == true)
        {
            myTransform    = transform;
            manaScript     = GetComponent <Mana>();
            move           = GetComponent <PointAndClickMovement>();
            fireProjectile = GetComponent <FireProjectile>();
            spawn          = GameObject.Find("SpawnManager").GetComponent <SpawnScript>();

            if (spawn.amIOnTheRedTeam == true)
            {
                iAmOnTheRedTeam = true;
            }
            if (spawn.amIOnTheBlueTeam == true)
            {
                iAmOnTheBlueTeam = true;
            }
        }
        else
        {
            enabled = false;
        }
        source = gameObject.GetComponent <AudioSource>();
    }
Exemple #4
0
    void startMovement()
    {
        SetMoving(true);
        placingObject = null;

        PointAndClickMovement.setMovementStatus(false);
        MainCanvas.mainCanvas.freezeOverride = true;

        if (placingObject.GetComponent <WorldInteractive>() != null)
        {
            placingObject.GetComponent <WorldInteractive>().beingMoved = true;
        }
    }
Exemple #5
0
 void resetInteraction()
 {
     SetPlacing(false);
     SetMoving(false);
     PointAndClickMovement.setMovementStatus(true);
     MainCanvas.mainCanvas.freezeOverride = false;
     ignoredPlanes.Clear();
     if (placingObject != null)
     {
         Destroy(placingObject);
         currentBuyObject = null;
     }
     OnPlacementInteract?.Invoke(false);
 }
Exemple #6
0
 // Use this for initialization
 void Start()
 {
     if (networkView.isMine)
     {
         shop = gameObject.GetComponent <ShopKeeper>();
         inv  = gameObject.GetComponent <InventoryGrid>();
         Transform triggerTransform = transform.FindChild("Trigger");
         HDScript    = triggerTransform.GetComponent <HealthAndDamage>();
         manaScript  = gameObject.GetComponent <Mana>();
         playerStats = gameObject.GetComponent <PlayerStats>();
         move        = gameObject.GetComponent <PointAndClickMovement>();
     }
     else
     {
         enabled = false;
     }
 }
Exemple #7
0
    // Use this for initialization
    void Start()
    {
        // Define the player's statistics window.
        statWindow = new Rect(nativeWidth - (nativeWidth - 1150), nativeHeight - 200, 200, 230);

        if (networkView.isMine)
        {
            teamSelectionScript = GameObject.Find("SpawnManager").GetComponent <CharacterSelection>();
            Transform triggerTransform = transform.FindChild("Trigger");
            HDScript   = triggerTransform.GetComponent <HealthAndDamage>();
            moveScript = transform.GetComponent <PointAndClickMovement>();
            spawn      = GameObject.Find("SpawnManager").GetComponent <SpawnScript>();

            // Assign the player's stats when a character is selected.
            AssignPlayerStats();
        }
        else
        {
            enabled = false;
        }
    }
    // Update is called once per frame
    void Update()
    {
        // Translate the projectile in the up direction (the pointed end of the projectile).
        myTransform.Translate(Vector3.up * projectileSpeed * Time.deltaTime);


        //If the ray hits something then execute this code.
        if (Physics.Raycast(myTransform.position, myTransform.up, out hit, range) &&
            expended == false)
        {
            //If the collider has the tag of map then..
            if (hit.transform.tag == "map")
            {
                expended = true;

                //Instantiate an explosion effect.
                Instantiate(projectileExplosion, hit.point, Quaternion.identity);

                //Destroy the projectile from the scene.
                Destroy(myTransform.gameObject);
            }

            if (hit.transform.tag == "RedTeamTrigger" || hit.transform.tag == "BlueTeamTrigger")
            {
                expended = true;

                //Instantiate an explosion effect.
                Instantiate(projectileExplosion, hit.point, Quaternion.identity);

                //Destroy the projectile from the scene.
                Destroy(myTransform.gameObject);

                // Access the HealthAndDamage Script of the enemy player and inform them that they have been attacked.
                // Also set the projectile damage equal to the half of the spellStat of the player and apply slow
                if (hit.transform.tag == "BlueTeamTrigger" && team == "red")
                {
                    PointAndClickMovement move = hit.transform.parent.gameObject.GetComponent <PointAndClickMovement>();
                    float slowRate             = 2.0f;
                    int   slowDuration         = 3;
                    move.Slow(slowRate, slowDuration);

                    PlayerStats     plstats  = spawn.redspawn.GetComponent <PlayerStats>();
                    HealthAndDamage HDScript = hit.transform.GetComponent <HealthAndDamage>();

                    HDScript.spellDamage      = plstats.spellStat / 2;
                    HDScript.iWasJustAttacked = true;
                    HDScript.hitBySpell1      = true;
                }

                // Access the HealthAndDamage Script of the enemy player and inform them that they have been attacked.
                // Also set the projectile damage equal to the half of the spellStat of the player and apply slow
                if (hit.transform.tag == "RedTeamTrigger" && team == "blue")
                {
                    PointAndClickMovement move = hit.transform.parent.gameObject.GetComponent <PointAndClickMovement>();
                    float slowRate             = 2.0f;
                    int   slowDuration         = 3;
                    move.Slow(slowRate, slowDuration);

                    PlayerStats     plstats  = spawn.bluespawn.GetComponent <PlayerStats>();
                    HealthAndDamage HDScript = hit.transform.GetComponent <HealthAndDamage>();

                    HDScript.spellDamage      = plstats.spellStat / 2;
                    HDScript.iWasJustAttacked = true;
                    HDScript.hitBySpell1      = true;
                }
            }
        }
    }