Example #1
0
    // Use this for initialization
    void Start()
    {
        maxLifeTimeInSeconds = lifeTimeInSeconds;
        if (!inMenu)
        {
            Time.timeScale = 1f;
            manager        = GameObject.Find("LevelManagerO").GetComponent <LevelManager> ();
            copterScript   = GameObject.FindObjectOfType <Copter> ();
        }
        crate    = gameObject.transform.parent.gameObject;
        animator = gameObject.transform.parent.GetComponent <Animator>();

        //spriteRenderer = crate.GetComponent<SpriteRenderer> ();

        /*if (crate.transform.FindChild ("BackGround") != null)
         *      bgRenderer = crate.transform.FindChild ("BackGround").GetComponent<SpriteRenderer> ();*/

        if (animator.GetInteger("status") == 0)
        {
            stationary = true;
        }
        else if (animator.GetInteger("status") == 1)
        {
            twoPhases = true;
        }
        else if (animator.GetInteger("status") == 3)
        {
            fourPhases = true;
        }

        floatyValue = gameObject.transform.parent.GetComponent <Rigidbody2D> ().mass * 30f;
        hinge       = GetComponent <HingeJoint2D> ();
    }
Example #2
0
    public static Vector2 AttractToTarget(Copter thisCopter, Vector2 target, float attractionMagnitude)
    {
        Vector2 direction       = target - thisCopter.Position();
        Vector2 normedDirection = direction / (Mathf.Max(direction.magnitude, 1.0f));

        return(normedDirection * attractionMagnitude);
    }
Example #3
0
        public int Create(Copter copter)
        {
            _context.Copters.Add(entity: copter);
            _context.SaveChanges();

            return(copter.Id);
        }
Example #4
0
    public override void Init(Copter copter)
    {
        base.Init(copter);

        splashPrefab   = (playerCopter.levelManager == null) ? null : playerCopter.levelManager.levelSplash;
        UpdateDelegate = SplashUpdate;
    }
        public IActionResult CreateCopter([FromBody] CopterAggregate copterDto)
        {
            var copter = new Copter().CreateFromDto(copterDto);
            var id     = _copterRepository.Create(copter);

            return(Ok($"Copter with ID: {copter.Id} were successfully created"));
        }
Example #6
0
 public override void Init(Copter copter)
 {
     base.Init(copter);
     cargoItems = new List <HookableObject>();
     manager    = copter.levelManager;
     copterMass = playerRb.mass;
 }
Example #7
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("copter"))
     {
         if (other.gameObject.transform.parent != transform.parent)
         {
             Instantiate(myParticuleSystem, transform.position, transform.rotation);
             Copter c = other.gameObject.GetComponent <Copter>();
             other.gameObject.GetComponent <BoxCollider>().enabled = false;
             MeshRenderer[] tempMR = transform.parent.GetComponentsInChildren <MeshRenderer>();
             foreach (MeshRenderer tMR in tempMR)
             {
                 tMR.enabled = false;
             }
             Invoke("Ressurect", timerBeforeResurect);
             c.Invoke("Ressurect", timerBeforeResurect);
             if (GetComponent <AudioSource>() != null)
             {
                 GetComponent <AudioSource>().Play();
             }
             myHelicopter.isDead   = true;
             c.myHelicopter.isDead = true;
         }
     }
 }
Example #8
0
    // Use this for initialization
    void Start()
    {
        manager = GameObject.Find("LevelManagerO").GetComponent <LevelManager>();
        copter  = GameObject.Find("Copter").GetComponent <Copter> ();

        saved = transform.FindChild("SavedBackground").FindChild("Saved").GetComponent <Text> ();
        cargo = transform.FindChild("CargoBackground").FindChild("Cargo").GetComponent <Text> ();
        clock = transform.FindChild("ImageClock").GetComponent <Image> ();
        //action = transform.FindChild ("ActionBackground").FindChild ("Action").GetComponent<Text> ();
        power      = transform.FindChild("PowerMeter").FindChild("Power").GetComponent <Slider> ();
        fuel       = transform.FindChild("Fuel").GetComponent <Image> ();
        fuelBorder = fuel.transform.FindChild("FuelMeter").GetComponent <Image>();

        if (resetButton == null)
        {
            resetButton = gameObject.transform.FindChild("ResetButton").gameObject;
            resetButton.GetComponent <Button>().onClick.AddListener(() => manager.Reset());
        }
        if (pauseButton == null)
        {
            pauseButton = gameObject.transform.FindChild("PauseButton").gameObject;
            pauseButton.GetComponent <Button>().onClick.AddListener(() => manager.pause());
        }

        levelTimeChallenge = LevelHandler.CurrentLevel.levelTimeChallenge;
        //if (manager.levelAction != 0)
        //    transform.FindChild ("ActionBackground").FindChild ("IsKill").GetComponent<Button> ().onClick.AddListener(() => copter.UseAction ());
        //else
        //    transform.FindChild ("ActionBackground").GetComponent<Image>().enabled = false;
    }
Example #9
0
        public override void OnAttach(ActorInstantiationDetails details)
        {
            base.OnAttach(details);

            theme = details.Params[0];

            switch (theme)
            {
            case 0:
            default:
                RequestMetadata("Enemy/LizardFloat");
                break;

            case 1:     // Xmas
                RequestMetadata("Enemy/LizardFloatXmas");
                break;
            }

            collisionFlags &= ~CollisionFlags.ApplyGravitation;

            SetHealthByDifficulty(1);
            scoreValue = 200;

            SetAnimation(AnimState.Idle);

            // Spawn copter
            Copter copter = new Copter();

            copter.OnAttach(new ActorInstantiationDetails {
                Api    = api,
                Params = details.Params
            });
            copter.Parent = this;
        }
    private void FollowerMovement(float attraction, float repulsionStrength, float repulsionDistance)
    {
        Copter leader = myArena.GetLeader();

        foreach (CircleCopter thisCopter in myArena.GetAllCopters())
        {
            //Attraction:
            Vector2 toLeader           = leader.Position() - thisCopter.Position();
            Vector2 toLeaderNormed     = toLeader / (Vector2.Distance(leader.Position(), thisCopter.Position()));
            Vector2 attractionMovement = toLeaderNormed * attraction;
            //Repulsion from leader:
            Vector2 repulsionFromLeader = repulsionStrength * Mathf.Exp(-0.5f * (toLeader.magnitude * toLeader.magnitude) / (repulsionDistance * repulsionDistance)) * toLeader;

            //Attraction to and repulsion from other copters:
            Vector2 repulsionMovement = new Vector2(0.0f, 0.0f);
            foreach (CircleCopter otherCopter in myArena.GetAllCopters())
            {
                if (thisCopter != otherCopter)
                {
                    CollisionResult cr = thisCopter.CollidesWithCopter(otherCopter);
                    Vector2         repulsionDirection = cr.CollisionPointThisObject - cr.CollisionPointOtherObject;
                    Vector2         repulsionVector    = repulsionStrength * Mathf.Exp(-0.5f * cr.Distance * cr.Distance / (repulsionDistance * repulsionDistance)) * repulsionDirection;
                    repulsionMovement += repulsionVector - attraction * repulsionDirection;
                }
            }
            //Position update:
            Vector2 update = (attractionMovement + repulsionFromLeader + repulsionMovement).normalized * 0.05f;
            thisCopter.SetPosition(thisCopter.Position() + update);
        }
    }
Example #11
0
    public override void Init(Copter copter)
    {
        base.Init(copter);

        UpdateDelegate = UseFuel;    //Set the update method
        currentFuel    = maxCapacity;
        manager        = GameObject.FindObjectOfType <LevelManager>();
    }
Example #12
0
    public static Vector2 Function3(Copter thisCopter, Vector2 otherCopter, float a, float b, float c)
    {
        Vector2 direction  = thisCopter.Position() - otherCopter;
        float   attraction = a;
        float   repulsion  = b * ((float)Math.Exp(-(direction.magnitude * direction.magnitude) / c));

        return(-direction * (attraction - repulsion));
    }
Example #13
0
    public override void Init(Copter copter)
    {
        base.Init(copter);

        //hook = playerCopter.CreateGameObject(hookPrefab, Vector3.zero, Quaternion.identity);

        CreateHook(hookPrefab, hookDistance, snapDistance);
    }
        public IActionResult UpdateCopter(int id, [FromBody] CopterAggregate copterDto)
        {
            var copter = new Copter().CreateFromDto(copterDto);

            _copterRepository.Update(id, copter);

            return(Ok($"Copter {copter.Brand} {copter.Name} with ID: {copter.Id} were successfully updated"));
        }
Example #15
0
    public UpdateMethod UpdateDelegate = () => { };     //Delegate method to run in update. Replace with the method that should run as update

    //Initializes the required members of the object
    public virtual void Init(Copter copter)
    {
        GiveName();
        playerRb     = copter.GetComponent <Rigidbody2D>(); //Get the reference to players rigidbody
        playerCopter = copter;
        playerCopter.AddToDictionary(this);                 //Add the new Upgrade to the copters upgrade list

        upgrade.Init(playerCopter.copterName + name);
    }
Example #16
0
 public void StartRefill()
 {
     if (copter == null)
     {
         copter = GameObject.Find("Copter").GetComponent <Copter>();
     }
     copter.fuelTank.FillTank();
     GameObject.Find("HUD").GetComponent <UIManager> ().refill = true;
 }
Example #17
0
    void OnTriggerEnter2D(Collider2D other)
    {
        Copter copter = other.GetComponent <Copter>();

        if (copter != null)
        {
            copter.Detonate();
        }
    }
Example #18
0
        public static bool Prefix(Copter __instance, ref Rigidbody ___r)
        {
            ___r = __instance.GetComponent <Rigidbody>();

            MethodInfo methodInfo = typeof(Copter).GetMethod("Move", BindingFlags.NonPublic | BindingFlags.Instance);

            __instance.StartCoroutine((IEnumerator)methodInfo.Invoke(__instance, new object[0]));

            return(false);
        }
 public override CollisionResult CollidesWithCopter(Copter other)
 {
     if (other.GetType().Equals(typeof(CircleCopter)))
     {
         CircleCopter otherCircleCopter = (CircleCopter)other;
         return(GeometryUtility.CircleCollision(this.Position(), this.Radius, otherCircleCopter.Position(), otherCircleCopter.Radius));
     }
     //That should not happen
     throw new NotImplementedException();
 }
    //This is a naive O(n^2) implementation. It can be accelerated using divide and conquer.
    public bool CollisionWithOtherCopters(Copter copter)
    {
        List <Copter> copters = GetAllCopters();

        if (GetLeader() != null)
        {
            copters.Add(GetLeader());
        }
        return(copters.Any(c => copter.CollidesWithCopter(c).IsCollided));
    }
Example #21
0
    private static Vector2 AvoidWalls(Copter copter, TunnelArena myArena, float repulsionMagnitude, float repulsionRadius)
    {
        Vector2 movementVector = new Vector2(0.0f, 0.0f);

        foreach (WallElement wall in myArena.AllWalls)
        {
            CollisionResult cr = copter.PolygonCircleCollision(wall.CornerPoints);
            movementVector += SwarmingFormulas.RepelWhenClose(cr.CollisionPointThisObject, cr.CollisionPointOtherObject, repulsionMagnitude, repulsionRadius);
        }
        return(movementVector);
    }
Example #22
0
        public void Update(int id, Copter copter)
        {
            var existedCopter = _context.Copters.Find(id);

            if (existedCopter != null)
            {
                existedCopter.Update(newCopter: copter);
                _context.Copters.Update(entity: existedCopter);
            }

            _context.SaveChanges();
        }
Example #23
0
    // Use this for initialization
    void Awake()
    {
        gameState = GameState.PreGame;

        if (GameObject.Find("GameManager") != null)
        {
            gameManager = GameObject.Find("GameManager").GetComponent <GameManager>();
            gameManager.load();
            //copters = new GameObject[gameManager.getCopterAmount()];
        }
        crateAmount     = countCrates();
        actionsPerLevel = maxActionsPerLevel;
        if (pauseScreen == null)
        {
            pauseScreen = GameObject.Find("PauseScreen");
        }
        if (HUD == null)
        {
            HUD = GameObject.Find("HUD");
        }
        if (resetButton == null)
        {
            resetButton = HUD.transform.FindChild("ResetButton").gameObject;
            resetButton.SetActive(false);
        }

        objectives            = GameObject.FindObjectOfType <MissionObjectives>();
        objectives.Objective1 = LevelHandler.GetLevelSet(LevelHandler.CurrentLevel.setName).objective1;
        objectives.Objective2 = LevelHandler.GetLevelSet(LevelHandler.CurrentLevel.setName).objective2;
        objectives.Objective3 = LevelHandler.GetLevelSet(LevelHandler.CurrentLevel.setName).objective3;

        //objectives.refreshLevelObjectives();
        //copter instantiate
        if (copterSpawnPoint == null)
        {
            copterSpawnPoint = GameObject.Find("CopterSpawn");
        }
        if (gameManager != null)
        {
            copter = Instantiate(gameManager.CurrentCopter, copterSpawnPoint.transform.position, Quaternion.identity) as GameObject;
        }

        copter.name  = "Copter";
        copterScript = copter.GetComponent <Copter>();
        cargoSize    = copterScript.cargo.maxCapacity;


        resetCountdown = 3f;
        if (GameObject.FindObjectOfType <TutorialScript> () == null)
        {
            StartCoroutine(PreGame());
        }
    }
Example #24
0
    private Vector2 startPosition;      //The starting point from which the fish should start the jump

    void Start()
    {
        copter      = GameObject.Find("Copter").GetComponent <Copter>();
        _rigidbody  = GetComponent <Rigidbody2D>();
        _transform  = transform;
        forceVector = new Vector2(0, jumpForce);

        waterSplash = Instantiate(waterSplash, Vector3.zero, Quaternion.identity) as GameObject;
        waterLevel  = GameObject.FindObjectOfType <LevelManager>().getWaterLevel();

        splashed      = true;
        startPosition = _transform.position;
    }
Example #25
0
    public static void LeaderMovement(TunnelArena myArena, float speed)
    {
        Copter  leader         = myArena.GetLeader();
        Vector2 movementVector = new Vector2(0.0f, 0.0f);

        movementVector += SwarmingFormulas.AttractToTarget(leader, myArena.GetTarget(), 0.5f);
        movementVector += AvoidWalls(leader, myArena, 1, 0.1f);
        if (movementVector.magnitude > 1.0f)
        {
            movementVector.Normalize();
        }
        leader.SetPosition(leader.Position() + (movementVector * speed));
    }
Example #26
0
 public CopterDto(Copter copter)
 {
     Id              = copter.Id;
     Name            = copter.Name;
     Status          = copter.Status.ToString();
     Latitude        = copter.Latitude;
     Longitude       = copter.Longitude;
     CostPerMinute   = copter.CostPerMinute;
     BrandName       = copter.Brand.Name;
     MaxSpeed        = copter.MaxSpeed;
     MaxFlightHeight = copter.MaxFlightHeight;
     DroneType       = copter.DroneType.ToString();
     Control         = copter.Control.ToString();
 }
Example #27
0
//    protected virtual void OnEnable() {
//        EventManager.StartListening("HookDied", DetachHook);
//    }
//    protected virtual void OnDisable() {
//        EventManager.StopListening("HookDied", DetachHook);
//    }

    protected virtual void Start()
    {
        manager       = GameObject.Find("LevelManagerO").GetComponent <LevelManager>();
        copter        = GameObject.Find("Copter").GetComponent <Copter>();
        hookScript    = copter.HookScript;
        joint         = GetComponent <HingeJoint2D>();
        floating      = GetComponent <FloatingObject>();
        joint.enabled = false;

        timer = timeToLive;

        if (useTimer == true)
        {
            UpdateMethod += Timer;
        }
    }
Example #28
0
    protected float direction;                  //Based on the copter x-scale the direction the copter is going

    public override void Init(Copter copter)
    {
        base.Init(copter);

        GameObject hud = GameObject.Find("HUD");

        if (hud == null)
        {
            return;
        }

        if (createSwitchButton == true)
        {
            GameObject switchButton = copter.CreateGameObject(switchButtonPrefab, Vector3.zero, Quaternion.identity);
            switchButton.transform.SetParent(hud.transform);
            RectTransform swRect = switchButton.GetComponent <RectTransform> ();
            swRect.anchoredPosition = new Vector2(Screen.width * 0.91f, Screen.height * 0.356f);
            swRect.sizeDelta        = new Vector2(Screen.width * 0.095f, Screen.height * 0.178f);
            swRect.localScale       = Vector3.one;

            Button b = switchButton.GetComponent <Button> ();
            b.onClick.AddListener(() => SwitchDirection());
        }

        GameObject button = copter.CreateGameObject(turboButtonPrefab, turboButtonPrefab.transform.position, Quaternion.identity);

        button.transform.SetParent(hud.transform);
        button.transform.SetSiblingIndex(0);
        RectTransform rect = button.transform as RectTransform;

        rect.anchoredPosition = new Vector2(Screen.width * 0.91f, Screen.height * (0.19f / 2f));
        rect.sizeDelta        = new Vector2(Screen.width * 0.15f, Screen.height * 0.18f);
        rect.localScale       = Vector3.one;

        buttonRectangle = new Rect();

        buttonRectangle.x     = rect.anchoredPosition.x - rect.sizeDelta.x * 0.5f;
        buttonRectangle.width = rect.sizeDelta.x;

        buttonRectangle.y      = rect.anchoredPosition.y - rect.sizeDelta.y * 0.5f;
        buttonRectangle.height = rect.sizeDelta.y;

        UpdateDelegate = TurbineUpdate;
    }
Example #29
0
    // Use this for initialization
    void Start()
    {
        CopterInfos = new Dictionary <int, CopterInfo>();
        for (int i = 0; i < copters.Length; i++)
        {
            Copter c = Instantiate(copters[i]).GetComponent <Copter>();
            CopterInfos.Add(i, c.GetCopterInfo(i));
            c.Disable();
        }

        if (!PlayerPrefs.HasKey("First"))
        {
            save();
        }
        else
        {
            load();
        }
    }
Example #30
0
    public override void Init(Copter copter)
    {
        base.Init(copter);

        copterTr = playerRb.transform;
        copter.fuelTank.TankDepleted += OutOfFuel;      //Subscribe to the fuel tanks TankEmpty event
        copter.fuelTank.TankFilled   += TankFilled;
        UpdateDelegate = FuelUpdate;                    //Start with having fuel

        tempHoldTime = holdTime;
        if (PlayerPrefs.HasKey(SaveStrings.sAutoHoover))
        {
            useAutoHoover = PlayerPrefsExt.GetBool(SaveStrings.sAutoHoover);
        }
        else
        {
            useAutoHoover = true;
        }
    }
Example #31
0
        void Init(IntPtr pParam)
        {
            // get subsystems

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RESOURCE_MANAGER, out p_sub_sys);
            pResMan = (IResourceManager)p_sub_sys;

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_INPUT, out p_sub_sys);
            pInput = (IInput)p_sub_sys;
            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RENDER, out p_sub_sys);
            pRender = (IRender)p_sub_sys;
            pRender.GetRender2D(out pRender2D);

            // create arrays
            IEngineBaseObject pObj = null;
            pTextures = new ITexture[TexCount];
            pShadows = new ITexture[ShadowCount];
            pMeshes = new IMesh[MeshCount];

            // loading data
            pResMan.Load(RESOURCE_PATH + "sounds\\helicopter.wav", out pObj, 0);
            pSound = (ISoundSample)pObj;
            pSound.PlayEx(out pSoundChannel, E_SOUND_SAMPLE_PARAMS.SSP_LOOPED);

            for (int i = 0; i < TexCount; i++)
            {
                uint flags = TexNames[i].Contains("grass") ? (uint)(E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_BILINEAR | E_TEXTURE_LOAD_FLAGS.TLF_COORDS_REPEAT) : (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D;
                pResMan.Load(RESOURCE_PATH + TexNames[i], out pObj, flags);
                pTextures[i] = (ITexture)pObj;
            }

            pTextures[6].SetFrameSize(256, 256); // zombie sprite splitting

            for (int i = 0; i < MeshCount; i++)
            {
                pResMan.Load(RESOURCE_PATH + MeshNames[i], out pObj, (uint)E_MESH_MODEL_LOAD_FLAGS.MMLF_FORCE_MODEL_TO_MESH);
                pMeshes[i] = (IMesh)pObj;
            }

            // render shadows
            for (int i = 0; i < MeshCount; i++)
            {
                RenderMeshToTexture(out pShadows[i], pMeshes[i], pTextures[i]);
            }

            // render rotor shadow
            pResMan.CreateTexture(out pShadows[5], null, 256, 256, E_TEXTURE_DATA_FORMAT.TDF_RGBA8, E_TEXTURE_CREATE_FLAGS.TCF_DEFAULT, E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_BILINEAR);
            pRender.SetRenderTarget(pShadows[5]);
            TPoint2 coords = new TPoint2(128f, 128f);
            TColor4 col = TColor4.ColorWhite();
            pRender2D.DrawCircle(ref coords, 100, 64, ref col, E_PRIMITIVE2D_FLAGS.PF_FILL);
            pRender.SetRenderTarget(null);

            // gather, fill and init 3d-objects data
            MyMeshes = new MyMesh[8]
            {
                new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2( 900f, 500f), new TPoint3(400f, 400f, 500f), 225),
                new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2(-250f, 300f), new TPoint3(400f, 400f, 500f), 225),
                new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2( 800f, 200f), new TPoint3(400f, 400f, 400f), 225),
                new MyMesh(pMeshes[1], pTextures[1], pShadows[1], new TPoint2(   0f, 450f), new TPoint3(300f, 300f, 400f), 175),
                new MyMesh(pMeshes[1], pTextures[1], pShadows[1], new TPoint2(  50f, 750f), new TPoint3(300f, 300f, 300f), 175),
                new MyMesh(pMeshes[2], pTextures[2], pShadows[2], new TPoint2( 500f, 150f), new TPoint3(400f, 400f, 500f), 225),
                new MyMesh(pMeshes[3], pTextures[3], pShadows[3], new TPoint2( 180f, 150f), new TPoint3(400f, 400f, 600f), 200),
                new MyMesh(pMeshes[3], pTextures[3], pShadows[3], new TPoint2( 600f, 550f), new TPoint3(400f, 400f, 600f), 200, 90)
            };

            copter = new Copter(new MyMesh(pMeshes[4], pTextures[4], pShadows[4], new TPoint2(), new TPoint3(600, 600, 600), 200, 0, true), pTextures[5], pShadows[5]);
            zombie = new Zombie(pTextures[6]);
        }