Пример #1
0
    public void Update()
    {
        // Unfortunately, seeds are DEACTIVATED when I pick them up, and update is not called.
        // So we make them a gadget esque thing that calls update even on inactive objects.
//		Debug.Log("updateing");
        plantable = false;
        if (equipped)
        {
            activeFloor = GetActiveFloor();
            if (activeFloor)
            {
                floorSquares = activeFloor.GetPanels(this);
                plantable    = activeFloor.seedSizeMatchesFloorSquares;

                // Allow player to right-click with seed selected to flip its z and z
            }
        }
        if (Input.GetMouseButtonDown(1))
        {
            FlipXZ();
            GadgetThrow.inst.UpdateAmmoGraphics(true);
        }
        foreach (LevelMachineMatrixFloor mf in previousFloors)
        {
            if (activeFloor != mf)
            {
                mf.SeedUnequipped();
            }
        }
//		Debug.Log(" UPDS plantable;"+plantable+",florsqct:"+floorSquares.Count);
    }
Пример #2
0
    public LevelMachineMatrixFloor GetActiveFloor()
    {
        LevelMachineMatrixFloor[] mflrs   = FindObjectsOfType <LevelMachineMatrixFloor>();
        LevelMachineMatrixFloor   closest = null;
        float dist = Mathf.Infinity;

        foreach (LevelMachineMatrixFloor mf in mflrs)
        {
            float diff = Vector3.SqrMagnitude(mf.transform.position + new Vector3(mf.sizeX / 2f * mf.gridScale, 0, mf.sizeZ / 2f * mf.gridScale) - Player.inst.transform.position);
            if (diff < dist)
            {
                dist    = diff;
                closest = mf;
            }
        }
        return(closest);
    }
Пример #3
0
 public void Init(LevelMachineMatrixFloor lmf)
 {
     matrixFloor = lmf;
     name        = positionX + "," + positionZ;
 }