示例#1
0
    void CheckShoot()
    {
        Ray        r = new Ray(transform.position + (Vector3.up * 1.38f), transform.TransformDirection(Vector3.forward) * 50);
        RaycastHit hit;

        if (Physics.Raycast(r, out hit, 50))
        {
            if (hit.collider.tag == "OtherPlayer" || hit.collider.tag == "MyPlayer")
            {
                hc = hit.collider.GetComponent <SinglePlayerControl>();
                if (!following)
                {
                    Debug.Log("Attempting to follow new target");
                    Invoke("SetPos", 0.5f);
                }
                following = true;
                rCD      -= Time.deltaTime;
                if (rCD <= 0)
                {
                    hc        = null;
                    following = false;
                    control.CmdShoot();
                    rCD = ReflexSpeed;
                }
            }
            else
            {
                rCD = ReflexSpeed;
            }
        }
    }
示例#2
0
 void Update()
 {
     if (mGen == null)
     {
         mGen = FindObjectOfType <MazeGenerator>();
     }
     else if (m == null)
     {
         m = mGen.currentMaze();
     }
     else if (pControl == null)
     {
         GameObject g = GameObject.FindGameObjectWithTag("MyPlayer");
         if (g != null)
         {
             pControl = g.GetComponent <SinglePlayerControl>();
         }
     }
     else
     {
         pOffset = pixelOffset();
         cellDim = cellDimenstions();
         icon.rectTransform.sizeDelta    = new Vector2(cellDimenstions().x, cellDimenstions().y);
         icon.transform.localEulerAngles = new Vector3(0, 0, -pControl.transform.localEulerAngles.y + 90);
         Vector2 pPos = pControl.pos();
         float   x    = pixelOffset().x + (cellDimenstions().x *pPos.x) + (cellDimenstions().x / 2);
         float   y    = pixelOffset().y + (cellDimenstions().y *pPos.y) + (cellDimenstions().x / 2);
         Vector2 v    = new Vector2(x, y);
         GetComponent <RectTransform>().anchoredPosition = v;
     }
 }
示例#3
0
	void Update () 
	{
		if(mGen == null)
			mGen = FindObjectOfType<MazeGenerator>();
		else if(m == null)
		{
			m = mGen.currentMaze();
		}
		else if(pControl == null)
		{
			GameObject g = GameObject.FindGameObjectWithTag("MyPlayer");
			if(g != null)
				pControl = g.GetComponent<SinglePlayerControl>();
		}
		else
		{
			pOffset = pixelOffset();
			cellDim = cellDimenstions();
			icon.rectTransform.sizeDelta = new Vector2(cellDimenstions().x, cellDimenstions().y);
			icon.transform.localEulerAngles = new Vector3(0,0,-pControl.transform.localEulerAngles.y + 90);
			Vector2 pPos = pControl.pos();
			float x = pixelOffset().x + (cellDimenstions().x*pPos.x) + (cellDimenstions().x/2);
			float y = pixelOffset().y + (cellDimenstions().y*pPos.y) + (cellDimenstions().x/2);
			Vector2 v = new Vector2(x,y);
			GetComponent<RectTransform>().anchoredPosition = v;
		}
	}
    public void CmdShoot()
    {
        StopCoroutine("LineShow");
        StartCoroutine("LineShow");
        Ray r = new Ray(transform.position + (Vector3.up * 1.38f), transform.TransformDirection(Vector3.forward) * 50);

        Debug.DrawRay(transform.position + (Vector3.up * 1.38f), transform.TransformDirection(Vector3.forward) * 50, Color.blue, 1);
        RaycastHit hit;

        if (PlayerControl)
        {
            AudioSource Source = GetComponent <AudioSource>();
            Source.PlayOneShot(Shot);
        }
        if (Physics.Raycast(r, out hit, 50))
        {
            if (hit.collider.tag == "OtherPlayer" || hit.collider.tag == "MyPlayer")
            {
                SinglePlayerControl opc = hit.collider.GetComponentInParent <SinglePlayerControl>();
                changeScore(10);
                opc.RpcKill();
                opc.kill();
            }
        }
    }
示例#5
0
	public void Init()
	{
		control = GetComponent<SinglePlayerControl>();
		control.enabled = true;
		control.RandomPlacement();
		MoveQ = new Stack<Direction>();
		StartCoroutine("afterFrame");
	}
示例#6
0
 public void Init()
 {
     control         = GetComponent <SinglePlayerControl>();
     control.enabled = true;
     control.RandomPlacement();
     MoveQ = new Stack <Direction>();
     StartCoroutine("afterFrame");
 }
示例#7
0
    public void ClickSP()
    {
        GameObject          splr  = GameObject.FindGameObjectWithTag("MyPlayer");
        SinglePlayerControl sctrl = splr.GetComponent <SinglePlayerControl>();

        if (sctrl.tag == "MyPlayer" && sctrl != null)
        {
            sctrl.Shoot();
            Debug.Log("Shot");
        }
    }
示例#8
0
    void CheckSeen()
    {
        Ray r = new Ray(transform.position + (Vector3.up * 1.38f), transform.TransformDirection(Vector3.forward) * 50);

        Debug.DrawRay(transform.position + (Vector3.up * 1.38f), transform.TransformDirection(Vector3.forward) * 50, Color.blue, 1);
        RaycastHit hit;

        if (Physics.Raycast(r, out hit, 50))
        {
            if (PlayerControl && (hit.collider.tag == "OtherPlayer" || hit.collider.tag == "MyPlayer"))
            {
                SinglePlayerControl opc = hit.collider.GetComponentInParent <SinglePlayerControl>();
                FindObjectOfType <ScoreSystem>().CurrentView = opc.name;
            }
            else if (PlayerControl)
            {
                FindObjectOfType <ScoreSystem>().CurrentView = "";
            }
        }
        else
        {
            FindObjectOfType <ScoreSystem>().CurrentView = "";
        }
    }
示例#9
0
	void CheckShoot()
	{
		Ray r = new Ray(transform.position+(Vector3.up*1.38f), transform.TransformDirection(Vector3.forward)*50);
		RaycastHit hit;
		if(Physics.Raycast(r, out hit, 50))
		{
			if(hit.collider.tag == "OtherPlayer" || hit.collider.tag == "MyPlayer")
			{
				hc = hit.collider.GetComponent<SinglePlayerControl>();
				if(!following)
				{
					Debug.Log("Attempting to follow new target");
					Invoke("SetPos", 0.5f);
				}
				following = true;
				rCD -= Time.deltaTime;
				if(rCD <= 0)
				{
					hc = null;
					following = false;
					control.CmdShoot();
					rCD = ReflexSpeed;
				}
			}
			else
				rCD = ReflexSpeed;
		}
	}