Ejemplo n.º 1
0
    void ObjectRay2()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            objectScript = rayed.GetComponent <ObjectScript> ();

            if (objectScript.rightInstrument == instrumentScript.instrName)
            {
                rightAnswers++;
                //Открыть замок
                if (objectScript.isLocked == true)
                {
                    objectScript.Opening();
                    wrong.text = null;
                }
                else
                {
                    wrong.text = "Замок уже открыт";
                }

                //rayed.SetActive (false);
                //Открыть крышку
                if (lockScript.isLocked)
                {
                    lockScript.Check();
                }
            }
            else
            {
                wrongAnswers++;
                Debug.Log("wrong instrument");
                wrong.text = "Нужен другой инструмент";
            }
        }
    }
Ejemplo n.º 2
0
 public void OnDrop(PointerEventData eventData)
 {
     //Ajout de l'icon dans le slot si vide
     if (!item)
     {
         ObjectScript objToAdd = ScriptableObject.CreateInstance <ObjectScript>();
         DragIconInventory.item.transform.SetParent(transform);
         removeButton.interactable = true;
         removeButtonIcon.enabled  = true;
         if (DragIconInventory.itemType == DragIconInventory._typeOfItem.Consumable)
         {
             objToAdd.itemType   = ObjectScript._typeOfItem.Consumable;
             objToAdd.objectName = DragIconInventory.name;
         }
         else if (DragIconInventory.itemType == DragIconInventory._typeOfItem.Bonus)
         {
             objToAdd.itemType   = ObjectScript._typeOfItem.Bonus;
             objToAdd.objectName = DragIconInventory.name;
         }
         else
         {
             objToAdd.itemType   = ObjectScript._typeOfItem.Skill;
             objToAdd.objectName = DragIconInventory.name;
         }
     }
 }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        // methods for moving and roatating the object to target position
        if (mObjectMoving)
        {
            float distCovered = (Time.time - mStartTime) * objectMoveSpeedToTarget;             // altering the object speed
            float fracJourney = distCovered / mJourneyLength;
            mSelectedGameObject.transform.position = Vector3.Lerp(mStartTransform, mEndTransform, fracJourney);
            mSelectedGameObject.transform.rotation = Quaternion.Lerp(mRotateStartTransform, mRotateEndTransform, fracJourney);
            if (mSelectedGameObject.transform.position == mEndTransform)
            {
                if (mMoveItBack)
                {
                    // move and rotate the object back if it doesn't match the type
                    ResetMoveVariables(mEndTransform, mStartTransform);
                    ResetRotateVariables(mRotateEndTransform, mRotateStartTransform);
                    mMoveItBack = false;
                }
                else
                {
                    mObjectMoving = false;

                    // resets material after it stops moving
                    // get ObjectScript that is attached to gameObject
                    ObjectScript objectScript = mSelectedGameObject.GetComponent <ObjectScript> ();
                    Renderer     rend         = mSelectedGameObject.GetComponent <Renderer> ();
                    rend.material       = (objectScript.material != null) ? objectScript.material : objectMaterial;
                    mSelectedGameObject = null;
                }
            }
        }
    }
    ////////////////////////////////////////////////

    private void UnitReachedTarget()
    {
        //Debug.Log("UnitReachedTarget!");

        locCount += 1;

        _currCubeScript   = unitScript.CubeUnitIsOn;
        _currPanelScript  = _currCubeScript._platform_Panel_Cube.GetCubePanel;
        _currObjectScript = _currPanelScript.gameObject.GetComponent <ObjectScript>();

        _currPanelScript.PanelIsDEActive();

        transform.SetParent(_TARGETCubeScript.transform);

        if (_newPathSet) // has a new location been clicked
        {
            SetNewpath();
        }
        else if (locCount < _nodes.Count) // move to next target
        {
            SetNextTarget();
        }
        else
        {
            FinishMoving();
        }
    }
Ejemplo n.º 5
0
    public void Begin(GameObject carrier)
    {
        if (!isActive)
        {
            isActive               = true;
            selectedObject         = carrier;
            scriptOfSelectedObject = (ObjectScript)selectedObject.GetComponent("ObjectScript");
            currentIndexOfPossibleStackedObject = 0;

            if (!scriptOfSelectedObject || scriptOfSelectedObject.possibleChildren.Length == 0 || scriptOfSelectedObject.possibleChildren[currentIndexOfPossibleStackedObject].Length == 0)
            {
                isActive = false;
                return;
            }

            ((SmoothCameraScript)GetComponent("SmoothCameraScript")).changeViewedObject(carrier);
            topDownAxisInverted = topDownAxisIsInverted();
            calculateDimensions();

            if (gridModus)
            {
                goToFirstAvailablePosition();
            }
            else
            {
                goToDefaultPosition();
            }
        }
    }
Ejemplo n.º 6
0
    void AddItemToInventory(string itemName, int playerid)
    {
        if (debug)
        {
            Debug.LogFormat("Le joueur avec l'id {0} veux ajouter un {1}", playerid, itemName);
        }
        var player = ColliderDirectoryScript.Instance.GetCharacterExposer(playerid);

        var objectToAdd = new ObjectScript();

        objectToAdd.objectName = itemName;
        switch (itemName)
        {
        case "Potion":
            objectToAdd.itemType = ObjectScript._typeOfItem.Consumable;
            break;

        case "Dash":
            objectToAdd.itemType = ObjectScript._typeOfItem.Skill;
            break;
        }

        objectToAdd.isConsume     = false;
        objectToAdd.isInInventory = true;

        player.inventoryScript.AddObjectInInventory(objectToAdd);
    }
Ejemplo n.º 7
0
    private void Start()
    {
        _Object     = GameObject.Find("Object").transform;
        ArrowCanvas = GameObject.Find("ArrowCanvas").transform;
        Vector123   = GameObject.Find("Vector123").GetComponent <Text>();

        Manual    = GameObject.Find("Manual");
        Ek        = GameObject.Find("Ek");
        isHidden  = true;
        isHidden1 = true;

        ObjectScript_ = GameObject.Find("Object").GetComponent <ObjectScript>();

        Mass = GameObject.Find("Mass").GetComponent <Text>();
        M    = GameObject.Find("M").GetComponent <Text>();
        T0   = GameObject.Find("T0").GetComponent <Text>();

        H       = GameObject.Find("H").GetComponent <Text>();
        V       = GameObject.Find("V").GetComponent <Text>();
        Ek_Text = GameObject.Find("Ek").GetComponent <Text>();
        Ep      = GameObject.Find("Ep").GetComponent <Text>();
        Ftr     = GameObject.Find("Ftr").GetComponent <Text>();
        T       = GameObject.Find("T").GetComponent <Text>();
        Q       = GameObject.Find("Q").GetComponent <Text>();

        Time.timeScale = 0;
    }
Ejemplo n.º 8
0
    private void setOriginator(GameObject orig)
    {
        ObjectScript origScript = (ObjectScript)orig.GetComponent("ObjectScript");

        canMove         = origScript.canMove;
        canScale        = origScript.canScale;
        canRotate       = origScript.canRotate;
        canBeStackedOn  = origScript.canBeStackedOn;
        topViewDistance = origScript.topViewDistance;

        localUpAxis        = origScript.localUpAxis;
        localAxisLeftRight = origScript.localAxisLeftRight;
        localAxisTopDown   = origScript.localAxisTopDown;
        gridSizeLeftRight  = origScript.gridSizeLeftRight;
        gridSizeTopBottom  = origScript.gridSizeTopBottom;
        children           = new ArrayList();
        possibleChildren   = origScript.possibleChildren;

        colInGrid = origScript.colInGrid;
        rowInGrid = origScript.rowInGrid;

        canBeDeleted = true;
        canBeCloned  = false;

        cloneID = origScript.lastUsedCloneID + 1;
        origScript.lastUsedCloneID = cloneID;
        original = orig;

        name = orig.name + cloneID;
    }
Ejemplo n.º 9
0
    void OnTriggerEnter2D(Collider2D col)
    {
        ObjectScript obj = col.gameObject.GetComponent <ObjectScript> ();

        switch (col.gameObject.tag)
        {
        case "cloud":
            registerHit(obj.penaltyLevel);
            break;

        case "fuel":
            collectFuel(0.65f);
            obj.collect();
            break;

        case "Cat":
            collectCat(obj);
            obj.collect( );
            break;

        default:
            Debug.Log("Unknown object type collided!");
            obj.kill();
            break;
        }
    }
Ejemplo n.º 10
0
    private RoomData ConvertRoomToData(GameObject room)
    {
        RoomData roomData = new RoomData();
        var      position = room.transform.position;

        roomData.x = (int)position.x;
        roomData.y = (int)position.y;
        ObjectScript os = room.GetComponent <ObjectScript>();

        roomData.rotation    = os.rotAdjust;
        roomData.isPrePlaced = os.preplacedRoom;
        roomData.objectNum   = os.objectNum;
        RoomStats roomStats = room.GetComponent <RoomStats>();

        roomData.crew                  = roomStats.currentCrew;
        roomData.usedRoom              = roomStats.usedRoom;
        roomData.roomLevel             = roomStats.GetRoomLevel();
        roomData.resourceActiveAmounts = new int[roomStats.resources.Count];
        for (var i = 0; i < roomStats.resources.Count; i++)
        {
            roomData.resourceActiveAmounts[i] = roomStats.resources[i].activeAmount;
        }

        return(roomData);
    }
Ejemplo n.º 11
0
 public override void Update(ObjectScript obj)
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         obj.TransitionToState(obj.IdleState);
     }
 }
Ejemplo n.º 12
0
    // Start is called before the first frame update
    void Start()
    {
        parent = GetComponent <ObjectScript>();
        float temp = parent.GetFloatVariable("WalkSpeed");

        Debug.Log(temp);
    }
Ejemplo n.º 13
0
    public void DeleteObject(GameObject item)
    {
        ObjectScript script = (ObjectScript)item.GetComponent("ObjectScript");

        Debug.Log(item.name);
        script.delete();
    }
Ejemplo n.º 14
0
 public void Init()
 {
     Debug.Log($"{this.Team} flag was created!");
     objectScript   = GetComponent <ObjectScript>();
     carrierPlayer  = null;
     this.isDropped = false;
 }
Ejemplo n.º 15
0
    // reseeting the scene when the start button is pushed.
    private void ResetScene()
    {
        // reseting variables to their default state
        CancelInvoke("ResetScene");
        mTimerCounter     = 0;
        timerDisplay.text = "0:00";
        failCount.text    = "0";
        successCount.text = "0";
        mGreenPoints      = 0;
        mRedPoints        = 0;

        // reseting camera to default position
        ResetCameraPosition();

        // reseting game objects to their positions and the materials for both target and movable object.
        GameObject[] gameObjects = GameObject.FindObjectsOfType <GameObject> ();
        for (int i = 0; i < gameObjects.Length; i++)
        {
            ObjectScript objScript = gameObjects [i].GetComponent <ObjectScript> ();
            if (objScript != null)
            {
                if (!objScript.isTargetObject)
                {
                    objScript.Reset();
                    gameObjects [i].GetComponent <Renderer> ().material = objectMaterial;
                }
                else
                {
                    gameObjects [i].GetComponent <Renderer> ().material = targetMaterial;
                }
            }
        }
    }
    void spawnObject(int objID)
    {
        float spawnPosition = Random.Range(-240f, 240f);

        // Try to relocate a spawned fuel cloud so that it hopefully doesn't overlap with
        // an obstacle. However, no rechecks are made if an obstacle spawns on top of a fuel
        // AFTER the fuel has been spawned.
        if (lastSpawnPosition != -1000f)
        {
            if (objID == 1)
            {
                if (spawnPosition > lastSpawnPosition - 50f &&
                    spawnPosition < lastSpawnPosition + 50f)
                {
                    spawnPosition = spawnPosition - Random.Range(100f, 300f);
                    if (spawnPosition < -240f)
                    {
                        spawnPosition = 240f - (Mathf.Abs(spawnPosition) - 240f);
                    }
                }
                lastFuelSpawnPosition = spawnPosition;
            }
        }

        // Modify object spawn location so that it ideally wouldn't spawn on top of a
        // fuel collectable if it spawns after one.
        if (lastFuelSpawnPosition != -1000f)
        {
            if (objID != 1)
            {
                if (spawnPosition > lastFuelSpawnPosition - 50f &&
                    spawnPosition < lastFuelSpawnPosition + 50f)
                {
                    spawnPosition = spawnPosition - Random.Range(100f, 300f);
                    if (spawnPosition < -240f)
                    {
                        spawnPosition = 240f - (Mathf.Abs(spawnPosition) - 240f);
                    }
                    lastFuelSpawnPosition = -1000f;                     //Allow next obstacle to spawn in the fuel's last position
                }
            }
        }

        lastSpawnPosition = spawnPosition;

        ObjectScript obj = Instantiate(
            spawnableObjects [objID],
            new Vector3(spawnPosition, 500, Random.Range(33, 99)),
            Quaternion.identity
            ).GetComponent <ObjectScript> ();

        spawnedObjects.Add(obj);
        obj.gameObject.transform.SetParent(MainCanvas, false);
        timer = Random.Range(level.spawnMin, level.spawnMax);

        // Randomize object's size
        float randSize = Random.Range(obj.gameObject.transform.localScale.x * 0.8f, obj.gameObject.transform.localScale.x * 1.2f);

        obj.gameObject.transform.localScale = new Vector3(randSize * RandomSign(), randSize, 1f);
    }
        public static void Postfix(ObjectScript __instance)
        {
            if (ObjectRegistry.Singleton.TryGetEntry(__instance.id, out ObjectInfo entry))
            {
                switch (entry.Type)
                {
                case ObjectType.ORE:
                    __instance.gameObject.name = "ore";
                    break;

                case ObjectType.TREE:
                    __instance.gameObject.name = "tree";
                    break;

                case ObjectType.PLANT:
                    __instance.gameObject.name = "plant";
                    break;

                case ObjectType.BUGSPOT:
                    __instance.gameObject.name = "bugspot";
                    break;

                default:
                    __instance.gameObject.name = "object";
                    break;
                }
            }
        }
Ejemplo n.º 18
0
    //-----------------------------------------------------reset timer---------------------------------------------------------------------
    public void ResetTimer()
    {
        totalizer.enabled = false;
        scoreBoard.SetActive(false);
        score           = 0;
        delayTimerDelay = 1;
        StartCoroutine(DelayTimerStart());

        if (buildIndex == 1)
        {
            printerScript.enabled = true;
            foreach (GameObject screen in screens)
            {
                screen.SetActive(true);
            }
            videoPlayer.Play();
        }


        foreach (GameObject item in Stage2Items)
        {
            item.layer = 9; // -------------perhaps this isn't needed

            objectscript = item.GetComponent <ObjectScript>();
            if (objectscript != null)
            {
                objectscript.StartingPositions();
            }
        }
    }
Ejemplo n.º 19
0
    IEnumerator ScoreCountActions()
    {
        yield return(new WaitForSeconds(2));

        foreach (GameObject item in Stage2Items)
        {
            objectscript = item.GetComponent <ObjectScript>();
            if (objectscript != null)
            {
                objectscript.showValue();
            }
        }
        yield return(new WaitForSeconds(3));

        scoreBoard.SetActive(true);
        totalizer.enabled = true;

        if (buildIndex == 1)
        {
            printerScript.enabled = false;
            foreach (GameObject screen in screens)
            {
                screen.SetActive(false);
            }
        }
    }
Ejemplo n.º 20
0
    public void changeViewedObject(GameObject go)
    {
        objectToViewScript = (ObjectScript) go.GetComponent("ObjectScript");

        if(elapsedTime > animTime && !interpolToTopView){
            cameraPositionBeforeTopView = Camera.main.transform.position;
            cameraRotationBeforeTopView = Camera.main.transform.rotation;
        }

        elapsedTime = 0.0f;
        interpolToTopView = true;
        startInterpolPos = Camera.main.transform.position;
        startInterpolRot = Camera.main.transform.rotation;

        Vector3 pos = objectToViewScript.transform.position;
        pos.y += objectToViewScript.topViewDistance;
        endInterpolPos = pos;

        Transform rot = Camera.main.transform;
        rot.rotation = Quaternion.identity;
        float angle = 0.0f;

        Vector3 rotp = new Vector3(90,0,0);
        rot.Rotate (rotp, Space.World);

        // make sure topDown en leftRight are correctly shown
        switch(objectToViewScript.localAxisLeftRight[0]){
            case 'X':
                angle = Vector3.Angle(rot.right, objectToViewScript.transform.right);
                break;
            case 'Y':
                angle = Vector3.Angle(rot.right, objectToViewScript.transform.up);
                break;
            case 'Z':
                angle = Vector3.Angle(rot.right, objectToViewScript.transform.forward);
                break;
        }

        rotp = new Vector3(0,angle,0);
        rot.Rotate (rotp, Space.World);

        bool flip = false;
        switch(objectToViewScript.localAxisLeftRight[0]){
            case 'X':
                flip = Math.Abs(Vector3.Angle(rot.right, objectToViewScript.transform.right)) > 2.0f;
                break;
            case 'Y':
                flip = Math.Abs(Vector3.Angle(rot.right, objectToViewScript.transform.up)) > 2.0f;
                break;
            case 'Z':
                flip = Math.Abs(Vector3.Angle(rot.right, objectToViewScript.transform.forward)) > 2.0f;
                break;
        }
        if(flip){
            rot.Rotate (-2*rotp, Space.World);
        }

        endInterpolRot = rot.rotation;
    }
Ejemplo n.º 21
0
 public void resetVillagerShaders()
 {
     foreach (GameObject obj in villagers)
     {
         Villager villagerScript = new ObjectScript <Villager>(obj).script;
         villagerScript.resetToDefaultShader();
     }
 }
Ejemplo n.º 22
0
 private void throwObject(Vector3 impulseDirection)
 {
     rb.mass -= grabbedObject.objectMass;
     grabbedObject.transform.SetParent(null);
     //  grabbedObject.GetComponent<Collider2D>().enabled = false;
     grabbedObject.GetComponent <Rigidbody2D>().velocity = -impulseDirection;
     grabbedObject = null;
 }
    // Collect cat and mark that it has been collected
    public void markCatCollected(ObjectScript cat)
    {
        Transform t = Instantiate(catCollectedMarker).GetComponent <Transform>();

        t.SetParent(UICanvas, false);
        t.localPosition = new Vector3(cat.transform.localPosition.x - 55f, -22.0f, cat.transform.localPosition.z);
        system.collectCat(cat.getCatLevel());
    }
Ejemplo n.º 24
0
    Rigidbody TBR;                                              // (ThisBatRigitbody) Это игрок на котором висит этот скрипт


    void Awake()                                                                                // Как только объект с этим скриптом попадёт на сцену
    {
        GM                = GameObject.Find("GameManager").GetComponent <GameManager>();        // Ложим в переменную GM скрипт GameManager с пустышки на сцене под темже именем GameManager
        GM.GoalEvent     += Goal;                                                               // Подписываем метод гол на событие GoalEvent
        GM.LastGoalEvent += LastGoal;                                                           // Подписываем метод LastGoal на событие LastGoalEvent
        OS                = GetComponent <ObjectScript>();                                      // В переменную ObjectScript загружаем ObjectScript
        TBR               = GetComponent <Rigidbody>();                                         // Ложим в переменную TBR Rigidbody биты на которой висит этот скрипт
    }
Ejemplo n.º 25
0
    void CoinCreator()
    {
        if (GameManager.canvasGO.enabled == false)
        {
            b = Instantiate(coin);

            b.transform.position = new Vector3(Random.Range(this.transform.position.x - 2, this.transform.position.x + 2), this.transform.position.y, this.transform.position.z);
        }
    }
Ejemplo n.º 26
0
    public string clone()
    {
        GameObject   clone       = (GameObject)Instantiate(gameObject, gameObject.transform.position, gameObject.transform.rotation);
        ObjectScript cloneScript = (ObjectScript)clone.GetComponent("ObjectScript");

        cloneScript.setOriginator(gameObject);

        return(clone.name);
    }
Ejemplo n.º 27
0
 public void underObjectOut()
 {
     underMeuble = false;
     objectIn    = null;
     foreach (CafardScript child in children)
     {
         child.underOut();
     }
 }
Ejemplo n.º 28
0
 public void underObjectIn(ObjectScript obj)
 {
     underMeuble = true;
     objectIn    = obj;
     foreach (CafardScript child in children)
     {
         child.underIn();
     }
 }
Ejemplo n.º 29
0
 public void delete()
 {
     foreach (GameObject child in children)
     {
         ObjectScript script = (ObjectScript)child.GetComponent("ObjectScript");
         script.delete();
     }
     gameObject.active = false;
 }
Ejemplo n.º 30
0
 public override object GetResource(ResourcePtr Ptr, Stream stream)
 {
     using (TextReader Reader = new StreamReader(stream))
         using (JsonReader JReader = new JsonTextReader(Reader))
         {
             ObjectScript os = Activator.CreateInstance(ScriptType) as ObjectScript;
             os.JObject = JObject.Load(JReader);
             return(os);
         }
 }
Ejemplo n.º 31
0
    public void detachChild(GameObject child)
    {
        if (child)
        {
            ObjectScript script = (ObjectScript)child.GetComponent("ObjectScript");

            children.Remove(child);
            child.transform.parent = null;
        }
    }
Ejemplo n.º 32
0
 // Use this for initialization
 void Start()
 {
     obj = transform.parent.GetComponent<ObjectScript>();
     switch (type) {
     case BlockType.Steel:
         obj.toggleGravity(false);
         break;
     case BlockType.Wood:
         //Can be destroyed by hand
     case BlockType.Stone:
         //Can be destroyed by bomb
         //Applying gravity
         break;
     }
 }
Ejemplo n.º 33
0
	public void Begin(string moveable){
			isActive = true;
			selectedObject = GameObject.Find(moveable);
			scriptOfSelectedObject = (ObjectScript) selectedObject.GetComponent("ObjectScript");	
			if(gridModus){
				currRowInGrid = scriptOfSelectedObject.rowInGrid;
				currColInGrid = scriptOfSelectedObject.colInGrid;
			}else{
				currLeftRightOnObject = scriptOfSelectedObject.posLeftRight;
				currTopDownOnObject = scriptOfSelectedObject.posTopDown;
				//currLeftRightOnObject = moveable.position.x;
			}
			
			if(scriptOfSelectedObject == null){
				isActive = false;
				return;
			}
			
			parentObject = scriptOfSelectedObject.getParent();
			if(parentObject == null){
				isActive = false;
				return;
			}		
						
			scriptOfParentObject = 	(ObjectScript) parentObject.GetComponent("ObjectScript");	
			
			((SmoothCameraScript) GetComponent("SmoothCameraScript")).changeViewedObject(parentObject);	
			topDownAxisInverted = topDownAxisIsInverted();
			calculateDimensions();
			
			
			if(gridModus){
				drawGrid();
			}else{
				drawNoGrid();
			}			
			
			move();		
	}
Ejemplo n.º 34
0
	public void Begin(GameObject carrier){
		if(!isActive){
			isActive = true;
			selectedObject = carrier;
			scriptOfSelectedObject = (ObjectScript) selectedObject.GetComponent("ObjectScript");	
			currentIndexOfPossibleStackedObject = 0;
			
			if(!scriptOfSelectedObject || scriptOfSelectedObject.possibleChildren.Length == 0 || scriptOfSelectedObject.possibleChildren[currentIndexOfPossibleStackedObject].Length == 0){
				isActive = false;
				return;
			}
						
			((SmoothCameraScript) GetComponent("SmoothCameraScript")).changeViewedObject(carrier);		
			topDownAxisInverted = topDownAxisIsInverted();
			calculateDimensions();
			
			if(gridModus)
				goToFirstAvailablePosition();		
			else
				goToDefaultPosition();	
		}
	}
Ejemplo n.º 35
0
	public void changeStackParent(GameObject selected, GameObject newParent){
		isActive = true;
		selectedObject = selected;
		scriptOfSelectedObject = (ObjectScript) selected.GetComponent("ObjectScript");	
			
		if(scriptOfSelectedObject == null){
			isActive = false;
			return;
		}
			
		parentObject = scriptOfSelectedObject.getParent();
		if(parentObject == null){
			isActive = false;
			return;
		}		
						
		scriptOfParentObject = 	(ObjectScript) parentObject.GetComponent("ObjectScript");			
		ObjectScript npScript = (ObjectScript) newParent.GetComponent("ObjectScript");	
		if(!npScript)
			return;
		if(npScript.canBeStackedOn == false)
			return;
	
		scriptOfParentObject.detachChild(selected);
		parentObject = newParent;						
		scriptOfParentObject = 	npScript;		
		((SmoothCameraScript) GetComponent("SmoothCameraScript")).changeViewedObject(newParent);	
		topDownAxisInverted = topDownAxisIsInverted();
		calculateDimensions();
		
		if(gridModus){
			selected.transform.parent = null;
			selected.transform.rotation = parentObject.transform.rotation;
			goToDefaultPositionGrid();				
			scriptOfParentObject.addChildInGrid(selected, currColInGrid, currRowInGrid);
		}			
		else{
			selected.transform.parent = null;
			selected.transform.rotation = parentObject.transform.rotation;
			goToDefaultPosition();	
			scriptOfSelectedObject.addChild(selected, currLeftRightOnObject, currTopDownOnObject);
		}
	}
Ejemplo n.º 36
0
 public void underObjectIn(ObjectScript obj)
 {
     underMeuble=true;
     objectIn=obj;
     foreach (CafardScript child in children)
         child.underIn();
 }
Ejemplo n.º 37
0
 void OnDestroy()
 {
     obj = transform.parent.GetComponent<ObjectScript>();
     obj.split (this.transform);
 }
Ejemplo n.º 38
0
 // Use this for initialization
 void Start()
 {
     Instance = this;
 }
Ejemplo n.º 39
0
 /// <summary>
 /// entrer dans un objet
 /// </summary>
 /// <param name="obj">Object.</param>
 public void inObject(ObjectScript obj)
 {
     isInObject=true;
     isSelected=false;
     goToMeuble=false;
     meubleToGo=null;
     objectIn=obj;
     if(obj.malus!=typeMalus.None)
         malusActived=obj.malus;
     Disappear();
     if(!IsInvoking("TakeMalus"))
         Invoke ("TakeMalus", ListConst.DamageDelay);
 }
Ejemplo n.º 40
0
 public void moveToMeuble(ObjectScript mb)
 {
     moveToDest(mb.transform.position);
     goToMeuble=true;
     meubleToGo=mb;
 }
Ejemplo n.º 41
0
    /// <summary>
    /// Sortir d'un objet
    /// </summary>
    public void outObject()
    {
        isInObject=false;
        objectIn=null;
        malusActived=typeMalus.None;
        Appear();
        if(!IsInvoking("Consume"))
            Invoke ("Consume",ListConst.consumDelay);

        goToMeuble=false;
        meubleToGo=null;
    }
Ejemplo n.º 42
0
 public void underObjectOut()
 {
     underMeuble=false;
     objectIn=null;
     foreach (CafardScript child in children)
         child.underOut();
 }
Ejemplo n.º 43
0
    void Update()
    {
        CheckLevel();//vérification du niveau actuel

        if(!isInObject)
        {

            if (isSelected && Input.GetMouseButtonDown(1))
            {
                mousePos=Camera.main.ScreenToWorldPoint (Input.mousePosition);
                mousePos.z=transform.position.z;
                piege=null;
                goToMeuble=false;
                meubleToGo=null;
                clickMeuble=false;
                clickPiege=false;
                Collider2D collide = Physics2D.OverlapCircle(mousePos,0.01f);
                if(Input.GetKey(KeyCode.LeftControl))
                {

                    rightClickMenu=true;
                    if(collide!=null)
                    {
                        if(collide.CompareTag("Meuble"))
                        {
                            clickMeuble=true;
                            meubleToGo=collide.GetComponent<ObjectScript>();
                        }
                        if(collide.CompareTag("Piege"))
                        {
                            clickPiege=true;
                            piege=collide.GetComponent<PoisonScript>();
                        }
                    }

                }
                else
                {
                    target=mousePos;
                    if(collide!=null && collide.CompareTag("Meuble"))
                    {
                        meubleToGo=collide.GetComponent<ObjectScript>();
                        moveToMeuble(meubleToGo);
                    }
                    else
                    {
                        moveToDest(target);
                    }
                    if(rightClickMenu)
                        closeRCM();
                }
            }

            if(isSelected && Input.GetMouseButtonDown(0))
            {
                isSelected=false;
                selectionBrig();
            }

            if(rightClickMenu && Input.GetMouseButtonUp(0))
                closeRCM();

            if (Input.GetMouseButton(0))
            {
                Vector3 camPos = Camera.main.WorldToScreenPoint (transform.position);
                camPos.y=LevelController.InvertMouseY(camPos.y);
                isSelected=LevelController.selectionRect.Contains(camPos);
                selectionBrig();
            }

            if (isSelected)
                viewInfo=true;
            else
                viewInfo=false;

        }

        if(life<=0)
        {
            Die();
        }
    }