Ejemplo n.º 1
0
 private void placementWalltoWall(GameObject otherObject, FollowMouse followScript, Collider otherCol)
 {
     if (this.transform.rotation == otherCol.transform.rotation)
     {
         if (!followScript.getRotate())
         {
             followScript.snap();
             otherObject.transform.position = parentObject.transform.position + new Vector3(parentObject.transform.GetComponent <BoxCollider>().bounds.size.x, 0, 0);
         }
         else if (followScript.getRotate())
         {
             followScript.snap();
             otherObject.transform.position = parentObject.transform.position - new Vector3(0, 0, parentObject.transform.GetComponent <BoxCollider>().bounds.size.z);
         }
     }
     else
     {
         followScript.enableSliding();
         if (!followScript.getRotate())
         {
             followScript.snap();
             otherObject.transform.position = parentObject.transform.position - new Vector3(-(otherCol.transform.GetComponent <BoxCollider>().bounds.extents.x - otherCol.transform.GetComponent <BoxCollider>().bounds.extents.z), 0, parentObject.transform.GetComponent <BoxCollider>().bounds.extents.z);
         }
         else if (followScript.getRotate())
         {
             followScript.snap();
             otherObject.transform.position = parentObject.transform.position + new Vector3(parentObject.transform.GetComponent <BoxCollider>().bounds.extents.x, 0, otherCol.transform.GetComponent <BoxCollider>().bounds.extents.z - otherCol.transform.GetComponent <BoxCollider>().bounds.extents.x);
         }
     }
 }
Ejemplo n.º 2
0
    void Start()
    {
        _manager = GameObject.FindGameObjectWithTag("Manager").GetComponent <Manager>();
        cursor   = GameObject.FindGameObjectWithTag("Symbol").GetComponent <FollowMouse>();

        //waking bar refs
        wakingBar       = GameObject.FindGameObjectWithTag("WakingBar");
        wakingBarScript = wakingBar.GetComponent <WakingBar>();
        wakingBarImage  = wakingBar.GetComponent <Image>();
        wakingBarRT     = wakingBar.GetComponent <RectTransform>();

        wakingBarImage.fillAmount = 0;

        //sleeping at start
        sleeping.SetActive(true);
        awake.SetActive(false);
        dancing.SetActive(false);

        asleep = true;

        //randomize audio
        int randomSnore = Random.Range(0, snores.Length);

        myAudio      = GetComponent <AudioSource>();
        myAudio.clip = snores[randomSnore];
        myAudio.Play();
    }
Ejemplo n.º 3
0
 private void placementWallToWall(GameObject otherObject, FollowMouse followScript, Collider otherCol)
 {
     if (this.transform.rotation == otherCol.transform.rotation)
     {
         followScript.snap();
         otherObject.transform.position = parentObject.transform.position + new Vector3(0, parentObject.transform.GetComponent <BoxCollider>().bounds.size.y, 0);
     }
 }
Ejemplo n.º 4
0
 void Start()
 {
     cameraFadeIn   = Object.FindObjectOfType <CameraFadeIn>();
     segmentManager = Object.FindObjectOfType <SegmentManager>();
     beeGuard       = transform.root.GetComponentInChildren <BeeGuard>();
     followMouse    = transform.root.GetComponentInChildren <FollowMouse>();
     animators      = transform.root.GetComponentsInChildren <Animator>();
     text           = GameObject.Find("Text");
 }
Ejemplo n.º 5
0
    public void Send()
    {
        fm = FollowMouse.instance;

        temp_building      = null;
        temp_building      = (GameObject)Instantiate(Resources.Load("Prefabs/Buildings/" + transform.gameObject.name));
        temp_building.name = transform.gameObject.name;
        fm.Pick(temp_building);
    }
Ejemplo n.º 6
0
    private void Awake()
    {
        if (instance != null)
        {
            Debug.LogError("More than 1 FollowMouse");
            return;
        }

        instance = this;
    }
    private void Awake()
    {
        GameObject player = GameObject.FindWithTag("Player");

        playerFollowMouse = player.GetComponent <FollowMouse>();

        playerShot = player.GetComponent <ShotDelay>();

        SetActive(false);
    }
Ejemplo n.º 8
0
 private void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this);
     }
     else
     {
         instance = this;
     }
 }
Ejemplo n.º 9
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
 }
Ejemplo n.º 10
0
    void OnTriggerEnter(Collider other)
    {
        /* if (other.tag.Equals("Tile"))
         * {
         *   if (tileScript.tileType.Equals(Tile.TileType.FOUNDATION))
         *       Destroy(this.gameObject);
         * }*/

        if (other.tag.Equals("Blueprint"))
        {
            otherObject  = other.gameObject;
            followScript = otherObject.GetComponent <FollowMouse>();
            if (!followScript.snapped)
            {
                if (tileScript.tileType.Equals(Tile.TileType.FOUNDATION))
                {
                    if (followScript.tileType.Equals(Tile.TileType.FOUNDATION))
                    {
                        placementFoundationToFoundation(otherObject, followScript);
                    }
                    else if (followScript.tileType.Equals(Tile.TileType.WALL) && !followScript.getRotate())
                    {
                        Debug.Log("Wall on foundation");
                        placementWallToFoundation(otherObject, followScript, other);
                    }
                }
                else if (tileScript.tileType.Equals(Tile.TileType.WALL))
                {
                    if (followScript.tileType.Equals(Tile.TileType.FOUNDATION))
                    {
                        return;
                    }
                    else if (followScript.tileType.Equals(Tile.TileType.FLOOR))
                    {
                        placementFloorToWall(otherObject, followScript, other);
                    }
                    else if (followScript.tileType.Equals(Tile.TileType.WALL))
                    {
                        placementWallToWall(otherObject, followScript, other);
                    }
                }
                else if (tileScript.tileType.Equals(Tile.TileType.FLOOR))
                {
                    if (followScript.tileType.Equals(Tile.TileType.FLOOR))
                    {
                        //otherObject.transform.position = parentObject.transform.position + new Vector3(parentObject.transform.GetComponent<BoxCollider>().bounds.size.x, 0, 0);
                        placementFoundationToFoundation(otherObject, followScript);
                    }
                }
            }
        }
    }
Ejemplo n.º 11
0
    // Start is called before the first frame update
    void Start()
    {
        rend      = GetComponentInChildren <Renderer>();
        submarine = GetComponent <Submarine>();
        weapon    = GetComponent <Weapon>();
        submarine.Init(rend.transform.parent, config);

        hurtable = GetComponent <Hurtable>();
        hurtable.Initialize(config.HealthConfig);
        ReadConfig();

        crosshair = GetComponentInChildren <FollowMouse>();
    }
Ejemplo n.º 12
0
    void SetUpComponents()
    {
        //club components
        followMouseComponent   = club.GetComponent <FollowMouse>();
        rotateTowardsComponent = club.GetComponent <RotateTowardsBall>();
        swingMeterComponent    = club.GetComponentInChildren <SwingForceMeter>();
        hitBallComponent       = club.GetComponentInChildren <HitBall>();

        //stage components
        navigateStageComponent = stage.GetComponent <NavigateStage>();

        //ball
        ballRB = ball.GetComponent <Rigidbody>();
    }
Ejemplo n.º 13
0
    void OnTriggerEnter(Collider other)
    {
        /*if (other.tag.Equals("Tile"))
         * {
         *  if (tileScript.tileType.Equals(Tile.TileType.WALL) && other.GetComponent<Tile>().tileType.Equals(Tile.TileType.FOUNDATION))
         *      Destroy(this.gameObject);
         *  if (tileScript.tileType.Equals(Tile.TileType.FOUNDATION) || tileScript.tileType.Equals(Tile.TileType.FLOOR))
         *      Destroy(this.gameObject);
         * }*/

        if (other.tag.Equals("Blueprint") && this.transform.rotation == other.transform.rotation)
        {
            otherObject  = other.gameObject;
            followScript = otherObject.GetComponent <FollowMouse>();

            if (tileScript.tileType.Equals(Tile.TileType.FOUNDATION))
            {
                if (followScript.tileType.Equals(Tile.TileType.FOUNDATION))
                {
                    placementFoundationToFoundation(otherObject, followScript);
                }
                else if (followScript.tileType.Equals(Tile.TileType.WALL) && !followScript.getRotate())
                {
                    placementWallToFoundation(otherObject, followScript, other);
                }
            }
            else if (tileScript.tileType.Equals(Tile.TileType.WALL))
            {
                if (followScript.tileType.Equals(Tile.TileType.FOUNDATION))
                {
                    return;
                }
                else if (followScript.tileType.Equals(Tile.TileType.FLOOR))
                {
                    placementFloorToWall(otherObject, followScript, other);
                }
                else if (followScript.tileType.Equals(Tile.TileType.WALL))
                {
                    placementWallToWall(otherObject, followScript, other);
                }
            }
            else if (tileScript.tileType.Equals(Tile.TileType.FLOOR))
            {
                if (followScript.tileType.Equals(Tile.TileType.FLOOR))
                {
                    placementFoundationToFoundation(otherObject, followScript);
                }
            }
        }
    }
Ejemplo n.º 14
0
    private void placementFloorToWall(GameObject otherObject, FollowMouse followScript, Collider otherCol)
    {
        followScript.snap();
        //otherObject.transform.position = parentObject.transform.position + new Vector3(0, parentObject.transform.GetComponent<BoxCollider>().bounds.extents.y, otherObject.transform.GetComponent<BoxCollider>().bounds.extents.z - parentObject.transform.GetComponent<BoxCollider>().bounds.extents.z);
        //Debug.Log(followScript.isPlaceable());

        float   xPos      = followScript.cursorPos.x;
        float   zPos      = followScript.cursorPos.z;
        Vector3 cursorPos = followScript.cursorPos;
        Vector3 temp      = this.transform.position - cursorPos;
        Vector3 temp2     = this.GetComponent <BoxCollider>().bounds.center;
        //Debug.Log("X: " + xPos);
        //Debug.Log("Z: " + zPos);
        //Debug.Log("X: " + Mathf.Abs(xPos));
        //Debug.Log(this.transform.rotation == new Quaternion(0.0f, 0.7f, 0.0f, 0.7f));
        float angle = Quaternion.Angle(this.transform.rotation, new Quaternion(0.0f, 0.7f, 0.0f, 0.7f));

        //Debug.Log(this.transform.rotation.Equals(new Quaternion(0.0f, 0.7f, 0.0f, 0.7f)) || this.transform.rotation == new Quaternion(0.0f, 0.7f, 0.0f, 0.7f));
        if (angle < 90f)
        {
            if (xPos > temp2.x + 0.5f)
            {
                otherObject.transform.position = parentObject.transform.position + new Vector3(otherObject.transform.GetComponent <BoxCollider>().bounds.extents.x - parentObject.transform.GetComponent <BoxCollider>().bounds.extents.x, parentObject.transform.GetComponent <BoxCollider>().bounds.extents.y - otherObject.transform.GetComponent <BoxCollider>().bounds.extents.y, 0);
            }
            else if (xPos < temp2.x - 0.5f)
            {
                otherObject.transform.position = parentObject.transform.position + new Vector3(-(otherObject.transform.GetComponent <BoxCollider>().bounds.extents.x - parentObject.transform.GetComponent <BoxCollider>().bounds.extents.x), parentObject.transform.GetComponent <BoxCollider>().bounds.extents.y - otherObject.transform.GetComponent <BoxCollider>().bounds.extents.y, 0);
            }
            else
            {
                otherObject.transform.position = parentObject.transform.position + new Vector3(0, parentObject.transform.GetComponent <BoxCollider>().bounds.extents.y - otherObject.transform.GetComponent <BoxCollider>().bounds.extents.y, 0);
            }
        }
        else
        {
            if (zPos > temp2.z + 0.5f)
            {
                otherObject.transform.position = parentObject.transform.position + new Vector3(0, parentObject.transform.GetComponent <BoxCollider>().bounds.extents.y - otherObject.transform.GetComponent <BoxCollider>().bounds.extents.y, (otherObject.transform.GetComponent <BoxCollider>().bounds.extents.z - parentObject.transform.GetComponent <BoxCollider>().bounds.extents.z));
            }
            else if (zPos < temp2.z - 0.5f)
            {
                otherObject.transform.position = parentObject.transform.position + new Vector3(0, parentObject.transform.GetComponent <BoxCollider>().bounds.extents.y - otherObject.transform.GetComponent <BoxCollider>().bounds.extents.y, -(otherObject.transform.GetComponent <BoxCollider>().bounds.extents.z - parentObject.transform.GetComponent <BoxCollider>().bounds.extents.z));
            }
            else
            {
                otherObject.transform.position = parentObject.transform.position + new Vector3(0, parentObject.transform.GetComponent <BoxCollider>().bounds.extents.y - otherObject.transform.GetComponent <BoxCollider>().bounds.extents.y, 0);
            }
        }
    }
Ejemplo n.º 15
0
    // Use this for initialization
    private void OnEnable()
    {
        ply    = GameObject.Find("player").GetComponent <Player>();
        me     = gameObject.GetComponent <Enemy>();
        weapon = GameObject.Find("player").transform.GetChild(0).gameObject.GetComponent <FollowMouse>();

        me.maxHp              = ply.maxHp;
        me.hp                 = me.maxHp;
        me.minDamage          = weapon.minDamage;
        me.maxDamage          = weapon.maxDamage;
        me.minRange           = 1;
        me.damageReducFlat    = ply.damageReducFlat;
        me.damageReducPercent = ply.damageReducPercent;
        me.moveSpeed          = ply.playerSpeed;
    }
Ejemplo n.º 16
0
    void Start()
    {
        segments = new List <Segment>(GetComponentsInChildren <Segment>());
        Object.FindObjectOfType <InputManager>().RegisterForRightClicks(gameObject);
        honeyBar    = Object.FindObjectOfType <HoneyBar>();
        followMouse = Object.FindObjectOfType <FollowMouse>();

        foreach (var slidable in GetComponentsInChildren <Slidable>())
        {
            slidable.enabled = false;
        }
        foreach (var rotatable in GetComponentsInChildren <Rotatable>())
        {
            rotatable.enabled = false;
        }
    }
Ejemplo n.º 17
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         if (hold == true)
         {
             Destroy(holding);
         }
         holding = Instantiate(tile1Blueprint, spawn.transform.position, Quaternion.identity);
         hold    = true;
     }
     else if (Input.GetMouseButtonDown(2))
     {
         if (hold == true)
         {
             Destroy(holding);
         }
         holding = Instantiate(tile2Blueprint, spawn.transform.position, Quaternion.identity);
         hold    = true;
     }
     else if (Input.GetMouseButtonDown(1))
     {
         FollowMouse followMouse = holding.GetComponent <FollowMouse>();
         if (followMouse.isPlaceable())
         {
             pos = holding.transform;
             Destroy(holding);
             hold    = false;
             holding = null;
             Instantiate(followMouse.tile, pos.position, pos.rotation);
         }
     }
     if (Input.GetButtonDown("Rotate"))
     {
         holding.GetComponent <FollowMouse>().rotate();
     }
     if (Input.GetButtonDown("Floor"))
     {
         if (hold == true)
         {
             Destroy(holding);
         }
         holding = Instantiate(tile3Blueprint, spawn.transform.position, Quaternion.identity);
         hold    = true;
     }
 }
Ejemplo n.º 18
0
    void OnTriggerEnter(Collider other)
    {
        /*Debug.Log("coliding with:" + other.gameObject.tag);
         * Debug.Log("bounds: " + other.bounds);
         * Debug.Log("Extends: " + other.bounds.extents);
         * Debug.Log("Max: " + other.bounds.max);
         * Debug.Log("Min: " + other.bounds.min);*/
        //Vector3 temp = other.transform.position;

        if (other.tag.Equals("Blueprint"))
        {
            otherObject  = other.gameObject;
            followScript = otherObject.GetComponent <FollowMouse>();
            if (tileScript.tileType.Equals(Tile.TileType.FOUNDATION))
            {
                if (followScript.tileType.Equals(Tile.TileType.FOUNDATION))
                {
                    placementFoundationToFoundation(otherObject, followScript);
                }
                else if (followScript.tileType.Equals(Tile.TileType.WALL) && followScript.getRotate())
                {
                    placementWallToFoundation(otherObject, followScript, other);
                }
            }
            else if (tileScript.tileType.Equals(Tile.TileType.WALL))
            {
                if (followScript.tileType.Equals(Tile.TileType.WALL))
                {
                    placementWalltoWall(otherObject, followScript, other);
                }
            }
            else if (tileScript.tileType.Equals(Tile.TileType.FLOOR))
            {
                Debug.Log("Floor to floor");
                if (followScript.tileType.Equals(Tile.TileType.FLOOR))
                {
                    //otherObject.transform.position = parentObject.transform.position + new Vector3(parentObject.transform.GetComponent<BoxCollider>().bounds.size.x, 0, 0);
                    placementFoundationToFoundation(otherObject, followScript);
                }
            }
        }
    }
Ejemplo n.º 19
0
    public void Awake()
    {
        rb            = GetComponent <Rigidbody2D>();
        pointerScript = GameObject.Find("Player").GetComponent <FollowMouse>();

        float angle = pointerScript.angle;

        rb.rotation = angle;

        horizontal = Mathf.Cos(angle * Mathf.Deg2Rad) * speed;
        vertical   = Mathf.Sin(angle * Mathf.Deg2Rad) * speed;

        GameObject spawn = GameObject.Find("barrel");

        transform.position = new Vector2(spawn.transform.position.x, spawn.transform.position.y);

        rb.AddForce(new Vector2(horizontal, vertical));

        GetComponent <AudioSource>().volume = PlayerPrefs.GetFloat("FXvolume");
        GetComponent <AudioSource>().Play();
    }
Ejemplo n.º 20
0
    private void Awake()
    {
        for (int i = 0; i < _plantPrefabs.Length; i++)
        {
            var newHotbarButton = Instantiate(_hotbarButtonPrefab);
            newHotbarButton.name = "HotKey_" + i;
            newHotbarButton.transform.SetParent(_hotbarTransform);
            newHotbarButton.GetComponent <Image>().sprite             = _plantPrefabs[i].GetComponent <SpriteRenderer>().sprite;
            newHotbarButton.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);
            newHotbarButton.GetComponentInChildren <Text>().text      = (i + 1).ToString();

            var index = i; // Need to create a local variable. Don't delete this

            newHotbarButton.GetComponent <Button>().onClick.AddListener(() => {
                OnButtonPressed(index);
            });
        }

        _ghostObject = Instantiate(_ghostPrefab).GetComponent <FollowMouse>();
        _ghostObject.gameObject.SetActive(false);
    }
Ejemplo n.º 21
0
    void SetPlatform(Vector3 mouseLocation)
    {
        string heldTag = heldObj.tag;
        float  rotation;

        if (heldObj.tag == "HeldSaveMe")
        {
            SaveMeHeldPlatform script = heldObj.GetComponent <SaveMeHeldPlatform>();
            rotation      = script.rotation;
            mouseLocation = heldObj.transform.position;
        }
        else
        {
            FollowMouse script = heldObj.GetComponent <FollowMouse>();
            rotation        = script.rotation;
            defaultRotation = rotation;
            Color col = script.currColor;
            if (col == Color.red)
            {
                // do not place platform if we are inside player
                return;
            }
        }
        Destroy(heldObj);
        heldObj = null;
        GameObject currPlatform = Instantiate(platforms[currentList[currPlatformNum - 1]], mouseLocation, Quaternion.identity);
        // instantiate actual static platform at location
        PlatformSet newScript = currPlatform.GetComponent <PlatformSet>();

        newScript.RotateTo(rotation);
        holding  = false;
        colorSet = false;
        float cooldown = cooldowns[currPlatformNum - 1];

        cooled[currPlatformNum] = false;
        hudScript.CoolDown(currPlatformNum, cooldown, Time.time);
        StartCoroutine(CoolDown(cooldown, currPlatformNum));
    }
Ejemplo n.º 22
0
 private void placementWallToFoundation(GameObject otherObject, FollowMouse followScript, Collider otherCol)
 {
     followScript.snap();
     otherObject.transform.position = parentObject.transform.position + new Vector3(parentObject.transform.GetComponent <BoxCollider>().bounds.extents.x - otherObject.transform.GetComponent <BoxCollider>().bounds.extents.x, parentObject.transform.GetComponent <BoxCollider>().bounds.extents.y + otherObject.transform.GetComponent <BoxCollider>().bounds.extents.y, 0);
 }
Ejemplo n.º 23
0
 void Start()
 {
     fm = GetComponent <FollowMouse>();
     rb = GetComponent <Rigidbody>();
 }
Ejemplo n.º 24
0
 private void placementFoundationToFoundation(GameObject otherObject, FollowMouse followScript)
 {
     followScript.snap();
     otherObject.transform.position = parentObject.transform.position + new Vector3(parentObject.transform.GetComponent <BoxCollider>().bounds.size.x, 0, 0);
 }
Ejemplo n.º 25
0
 private void Start()
 {
     buildManager = BuildManager.instance;
     followMouse  = FollowMouse.instance;
 }
Ejemplo n.º 26
0
 // Use this for initialization
 void Start()
 {
     rb2d       = GetComponent <Rigidbody2D>();
     controller = GameObject.FindGameObjectWithTag("GameController");
     fm         = GetComponent <FollowMouse>();
 }
Ejemplo n.º 27
0
    void Update()
    {
        Vector3 mouseLocation = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        mouseLocation.z = 0;
        bool buttonClicked = false;

        foreach (KeyValuePair <KeyCode, int> key in keys)
        {
            if (Input.GetKeyDown(key.Key) && cooled[key.Value])
            {
                if (colorSet)
                {
                    hudScript.ChangeColor(currPlatformNum, false);
                    currPlatformNum = key.Value;
                    mouseLocation   = heldObj.transform.position;
                }
                buttonClicked = true;
                // initialize platform at mouse location
                if (heldObj)
                {
                    Destroy(heldObj);
                }
                currPlatformNum = key.Value;
                hudScript.ChangeColor(currPlatformNum, true);
                holding = true;
                GameObject ourPlatFormSetter = heldVersions[currentList[currPlatformNum - 1]];
                if (ourPlatFormSetter.tag == "HeldSaveMe")
                {
                    float   width  = ourPlatFormSetter.transform.localScale.x / 2;
                    Vector3 setPos = new Vector3(player.transform.position.x + width, player.transform.position.y - width, 10);
                    heldObj = Instantiate(heldVersions[currentList[currPlatformNum - 1]], setPos, Quaternion.identity);
                }
                else
                {
                    heldObj = Instantiate(heldVersions[currentList[currPlatformNum - 1]], mouseLocation, Quaternion.identity);
                }
                FollowMouse followScript = heldObj.GetComponent <FollowMouse>();
                if (followScript != null)
                {
                    followScript.rotation = defaultRotation;
                }
                colorSet = true;
                break;
            }
        }
        if (Input.GetKeyDown(KeyCode.Escape) && holding && !buttonClicked)
        {
            // stop holding object and remove it from screen
            Destroy(heldObj);
            heldObj = null;
            holding = false;
            hudScript.ChangeColor(currPlatformNum, false);
            colorSet = false;
        }
        else if (Input.GetMouseButtonDown(0) && holding && !buttonClicked)
        {
            // if holding, object follows mouse until we instantiate it with mouse click
            SetPlatform(mouseLocation);
        }
        else if (Input.GetKeyDown(KeyCode.Space) && holding && !buttonClicked)
        {
            // if holding, object follows mouse until we instantiate it with spacebar
            SetPlatform(mouseLocation);
        }
    }
Ejemplo n.º 28
0
 private void placementFloorToWall(GameObject otherObject, FollowMouse followScript, Collider otherCol)
 {
     followScript.snap();
     otherObject.transform.position = parentObject.transform.position - new Vector3(0, 0, parentObject.transform.GetComponent <BoxCollider>().bounds.size.z);
 }
Ejemplo n.º 29
0
 private void OnEnable()
 {
     player = Player.player;
     atk    = player.gameObject.transform.GetChild(0).GetComponent <FollowMouse>();
 }